Implement first grid query function