fixed file filtering function