changed the location of session clearing