refactor user profile code