Refactor Ret conversion into its own function.