Fix js error when no query results found

this js error appears only when the first query does not return any result.