Corrected how the index used in valueAtPoint was calculated