fix extra close function