fixed stats.isDirectory call