refactor Position#queryAll as a generator and write #query in terms of it