refactor session manager