refactoring sum of absolute values