Fix incorrect var usage in replaceWith