created open and close callback functions