replaced vector with matrix