Sum function implemented