trigger events on open and close