reworking of query