Since you're not using ``gradient`` anymore you can drop this code and the loop below.