Added close function