inline script for event dispatch