merge s2 and s3 to a single function