fixed errors in readdir