New version of S3 code