What are the results of your result lines?

Do you have the two UDFs included in your script. If not, paste them to the bottom of the script.