fixed the script when called with symlinks