refactored filtering elements
added minimal query size