fix the leaving bug