Would include the check for the flash message here as well. Please also check if the user is indeed not logged in (checking the session)