Added ability to pass in a callback function