refactored control structures