aded algorithm