The commented lines are what I used to change it from an inline UDF to a multi-line UDF. You're correct in that it did not solve the problem, so I changed it back. Our DBA is going to add some comments of his own.
LinkedIn: https://www.linkedin.com/in/sqlrv
Website: https://www.sqlrv.com