update matrix when move