Changed method of determining the index of the trough so that the function works for a wider range of viscosities.