updated the controller logic

Now the controller should work correctly