move directory creation below the file filtering