refactoring of login.js and registration.js