Fixed compare function.