Move symlink detection to separate function