Wrap script in transaction