allow for no callback

The current implementation fails if no callback is provided. This PR just does a check to make sure it's defined before attempting to call the function. Makes usage simpler for use cases that don't require a callback.