fix compare function