Added error checking of login