refactor vactor and some part of matrix