generate_path code edited