method for calculation max and sum values