query updated to filer out nil