fixed the error handling for login