fixed handling for invalid login. Thanks to Quister