makeCacheMatrix <- function(x, ...) {
  cacheSolve <- x$solve()
  if(!is.null(cacheSolve)) {
    message("getting cached data")
    return(cacheSolve)
  }
  data <- x$get()
  cacheSolve <- solve(data, ...)
  x$solve(cacheSolve)
  cacheSolve
}