added support for functions (events with return values)