fixing bad session ending