merge code from afc163