updating the on and event methods to use function references.