adding close function