Refactored sessions.js