Adding another drop down filter to a database search

I folllowed a Corvid Example - “Search a database” and successfully adapted the code to fit my website, so that I could search the names of schools in my “School” database using a search bar and search for schools in particular counties by using a drop down filter. However now that I have tried to add a second drop down filter, the values from my “Genders” database are pulled in successfully to the drop down filter but no results are returned for this new drop down filter search. My code is as follows and still works fine for the two original searches (Name of School, and County of School) but not for the new drop down filter search by gender catered for at the school. As I wanted the same drop down filter search as for counties, I copied the code for the counties and adjusted the properties and databases accordingly. If anyone can suggest where I have gone wrong, I would be very grateful.

import wixData from “wix-data”;

$w.onReady(() => {
loadCounties();
loadGenders();
});

let lastFilterTitle;
let lastFilterCounty;
let lastFilterGender;
let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#iTitle’).value, lastFilterCounty, lastFilterGender);
}, 500);
}

export function iCounty_change(event, $w) {
filter(lastFilterTitle, $w(‘#iCounty’).value);
}
export function iGender_change(event, $w) {
filter(lastFilterTitle, $w(‘#iGender’).value);
}
function filter(title, county, gender) {
if (lastFilterTitle !== title || lastFilterCounty !== county || lastFilterGender !== gender) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains(‘schoolTitle’, title);
if (county)
newFilter = newFilter.contains(‘county’, county);
if (gender)
newFilter = newFilter.contains(‘gender’, gender);
$w(‘#dataset1’).setFilter(newFilter);
lastFilterTitle = title;
lastFilterCounty = county;
lastFilterGender = gender;
}
}

function loadCounties() {
wixData.query(‘Counties’)
.find()
.then(res => {
let options = [{“value”: ‘’, “label”: ‘All Counties’}];
options.push(…res.items.map(county => {
return {“value”: county.title, “label”: county.title};
}));
$w(‘#iCounty’).options = options;
});

}

function loadGenders() {
wixData.query(‘Genders’)
.find()
.then(res => {
let options = [{“value”: ‘’, “label”: ‘All Genders’}];
options.push(…res.items.map(gender => {
return {“value”: gender.title, “label”: gender.title};
}));
$w(‘#iGender’).options = options;
});

}