added some checks to make sure logged/non-logged in users have access to the correct pages