solved the cachematrix assignment