Fixing errors in controller logic