refactor code of user