better error handling for login