session refactoring