implementing before/after events