Perfect S2 and S3 function