last algo steps implemented