Added logic to controller