Added error handling for login