Wix Corvid Filtering

This is the code i used to filter

function filter(Level, Subject, Location){
if (lastFilterLevel !== Level || lastFilterSubject !== Subject || lastFilterLocation !== Location) {
let newFilter = wixData.filter();
if (Level)
newFilter = newFilter.contains(‘level’, Level)
if (Subject)
newFilter = newFilter.contains(‘subject’, Subject)
$w(‘#dataset1’).setFilter(newFilter);
if (Location)
newFilter = newFilter.contains(‘location’, Location);
$w(‘#dataset1’).setFilter(newFilter);
lastFilterLevel = Level;
lastFilterSubject = Subject;
lastFilterLocation = Location;
}
}

I am having an issue where the search will show duplicates even though i have seperated my database based on level. I think the issue might be due to the location and subject. How do i filter my database by level then subject then location. Is there a .then() function that I can use?