better error handling when logging in