a version with filetype check