New S edit code logic