Implemented Query function (not yet done)