copy modules stack before resolving it

otherwise the first hit empties the stack and subsequent hit will be
left with the empty modules stack