modified kernel max
added minIndex & maxIndex