Updated algorithm section