replace readdir by iterate