added matrix functions