Extract expand_paths method