Another PR.  And there are a LOT of things wrong with this function as written.