Created implementation for cacheMatrix