fixed isLoggedIn middleware