Re-write part of scripts/demo.pl