Moved the branching function to a new file ControlFlowHelpers