Add generate algorithm