pull function calls out of for loops in FilterMain.cpp