fixed logic in controller