added ability to close the functions