Changed placement of controller loop