fixes #4 for `replace`

see also 80d3e6b42f4eb4a4db9b9897895729ef20b65a80 and 47c00b774ce5385de2da09a1ca164ae32fbd47ee