apply optional callback function to result data