#15 Fixed replacement code