added a more accurated implementation of the query operation, as follow-up of the work done at issue #28