executing correct query