sample path finding algo