fix bug with sum, ruby should really have a sum_if method