Fix the remplacement. Code contributed by Andrej A Antonov aka polymorphm on Github