refactored the login stuff.