Fix a bug with the toEnder() internal function