getting the triu_indices into a temp variable would make this nicer (and saves to calculate them twice)