refactor to reduce indentation around users being logged-in or not.