fixed bug in script, improved syntax for calling external programs