Edited cachematrix.R as per assignments' requirements