adding my solution for cachematrix.R