add open and close event