Created user controller and refactored some code