BAC algorithm