improved error handling in login