made file filter function more reusable