made summing code more concise