added memoization for existsSync