minor refactoring of session