fixed bug with readdir (changed to stat)