Change find file function to be sync and read the dir.