real compare function
small improvement to fix