working on it....

I totaly rebuilt this UDF from scratch.