implement main logic for Session