Gradient can now be calculated for multiple xstar at a time