initial matrix implementation