fixes #2738 - handle multiple dynamic modulepaths
(cherry picked from commit e4ee928b03470ec085bc3c954405279421ccc52f)