cleaned up the way logged-in pages function