Refactored filter to better create useful queries