Loop replacement without modifying @raw

Fixes #107