Refactor file filtering for reability