See http://forum.cmsmadesimple.org/index.php/topic,45904.msg218703.html#msg218703 for all the info.. but totally more robust.