changed find_max_value method