added matrix stuff