More correct indexOfMaximumElement