Duplicates the logic at lines 1084-1090.  Can you find a way to unify both blocks?