my version of the cachematrix function