implements sum, max