Moved logic to controller folder