refactoring negative numbers code