added query discovery, preparation and execution