Added user controller and refractored some code