Refactor user.js