Added user accounts and refactored code