properly handle symlinks