refactored _cmp a little