Edited max method
Modify middle_element