fixing sum for non-linear terms... they were not being summed properly before (using new indices for the non-linear terms