cachematrix solution implemented