you don't show how you call the udf, nor you bothered to use code-tags.

follow some etiquette and we might be able to help with your issue.
_________________________
!

download KiXnet