optimize path search