Avoid overwriting existing value in initial matrix