Change on() definition to accept a function returning any