optimze path search