Moved logic to controllers