fix bug matrix