refactoring login stuff into login.js