new structure by filters option, and wrap code into functions