Added code to create run-time function.
Need to add it to event list