refactored user controller code