refactored to get sessions vars from db