fix query error/crash