Added cmp method's logic.