fix source handling for queries