move session examination inside the lock