refactored filtering so works