What's your question? Provided that
yes and
not are defined subs which do the appropriate things, this looks fine. If this code breaks, you'll need to provide more context (calling code, warnings, errors) before we can help.
Originally posted as a Categorized Answer.