corrected dynamic path logic