Fix my buggy js that was breaking query ordering