Hmm.. Use var instead of set. Also, I don't get the use of %chan. Whats wrong with $chan now? :P But good job :)