In reply to dave_59:
Thanks Dave! Trust me, i write better code than the pseudo code snippet above :)