move to top of ajaxReplacement function (even above the conditional)