control loop refactoring, simpler now