move a line requiring a logged-in user into an if statement checking the user's logged in