Tweaked the Error Checking and Redirection after login