Just put this at the top of your code:

function scan_event;