added a check if logged in