refactoring into session manager