Fix stats query