fixed deprecated path.exists; using fs.exists