Edited version of cachematrix.R