auto close function added