added sum() function by changing the way to map to functions easier