Added functionality for MatrixCache (Programming Assignment 2)