Move definition of with_index below

Right now is defined in the middle of two definitions of max function.