build and return the gradient as list