Update ag.cpp