Added callback feature

Callback on open and close.