matrix implemented