fix bug when dealing with directory entries