updated cachematrix to be able to invert a matrix and cache it