refactor 1 of login/registration