improving tensor contraction code