Updated single-script version