Is it possible to pass parameters to filter functions? If so, the two filter above could be simpliefied (they contain mostly the same code).

Minor for sure.