This version of removing undefined behavior seems to retain the original output.