added matrix operations code