refactor session API