refactor logged in and helper methods for sessions