add AGP algorithm
after debug, update code