add FilterSpans and simplify code