updated to suit new perl script