fix session logic