Refactor the file expand filter into a named function