expanded & debugged filter builder