Fixed bug in the function replacer