Remaining changes to control condition

These are the changes made to the control condition after the first pull request.
I see you writing the same 4 lines over and over again. Can we pull this out into its own function that you call when you need it? Or is there another way to simplify this?