refactored more of the authentication system