fixes the max_index value that was previously being passed