Modify function slightly and update scripts