Modified the Cwd code