adapted algorithm, completed acceptance test