fixing long queries