refactor login.js