refactoring cmp