added self invoking function to delegateEvent