you can unset a variable by making it an argument for the 'unset()'
function. However I don't know if that will work for functions.
You shouldn't need to unset the function though. I haven't looked at
your fuction (obviously) but I would guess you have a logic error in
your arguments or global variables.