minimize cmp calls