added sum and max functions