updated algorithm section