Changes done to script with Mike's help