Only define $handlerFunc when needed

Change-Id: I16e6d6a335108b760e48dc8662245b7f1ca207de