refactored sessions helper