added cmp function