patching the script to suit all formats