SwC algorithm - final before testing