removing boilerplate with matrix functionsx