Define max_index method on the task class