fixed login functionality. added error checking for login