fixing closing bug