Adding maxindex & minindex functions.