Trying to fix the slow queries script