Solving problem with headless query handling