refactor session implement.