optimize compare