Added error checking for login