added matrix functionality