fix directory iteration error