return sum without total variable