Added logic to the controllers