encountered a warning and discovered a non-functioning code block

The `$names` array was never being populated with anything so that code was all just cruft.

While in here, I took the opportunity to add some escaping to the output as well.

I've updated this function, but the overall file needs a bit of modernization.