fix close and open bug