Sum function working