All algorithm