I think this has to go before the first ¨if¨, otherwise the old_m.locations... stuff will never be evaluated.