Move compareRest into its own function.