Would it be possible to preserve M where coordinates are reused and set M to NaN where new coordinates are created?