Refactoring add and sub function.