add logic of eliminate and generation