clean up codes and build new framework for AutoReg