Fix broken check in JS queries