added the specialized cachedMatrix implementation according to the assignment's requirements