Everything looks good except that the new logic is not the same as the old one. The old one seems to be wrong, but I just want to make sure that we don't miss anything in changing the logic here.