Replaced path.existsSync with fs.existsSync