overhaul `compare` function.