Performance improvments by not doing filtering twice