My experience with this type of script and the same (or similar) problem has shown to me that the problem lies in the address that is being used. In your case $address(<nick>,3)

If the person connects from a different location, or via a different method, then the returned address might not match the stored address, and, although you recognize the two nicks as being the same person, the script does not, due to the fact that the addresses don't match.

Regretfully I have not been able to come up with a solution that works 100%, but I do intend to keep trying, and if I get one that works, I will post it. Likewise, if you get one, I hope that you will post it so that I (and probably others) will be able to make use of the additional information.