Update replace.js syntax

Move a comment block outside of fuction
General syntax updates (mostly braces changes I think)