Preliminayr change that would allow new aggregate functions to be defined (without changing existing behavior.) Also chaging the if statement to check for "sum" when deciding whether or not to calculate the sum is more clear. Add one more fix to make sure we don't try to do math on non-numerical data.