PathConstructor algorithm optimization