Added the callback functionality to the queryToStruct helper function.

Adam I've added the callback functionality to the QueryToStruct helper function as well.