Check for null handler before calling it