Moving location replace logic into a class, so that the code is slightly more sensible