add AC algorithm