Controller

Improved loop logic.