Refactoring get_path()