Fix use of getDirectoryContents
Simplify