Changed sum(scalar) to scalar since sum() is only defined for array type...