Added error checking to login process