Refactored code and added indirection with User class