Making query objects an iterator