Replace the ugly function with a mapping

Though we aren't using it, that function was still too ugly to be left
in the code. :/