optimization of isUserLoggedIn.