updated with matrix stuff