fixed bug where traversed past end of directory
clarified