added logic for working with session