resolves "undefined' issue in phantomjs

On firefox, if sub1 and sub2 were not given it didn't matter. On
phantomjs if either of them were not supplied, then the replaced word
would have "undefined" affixed at the front, back, or both sides of it.
This fix fixes that.