Fix Ag functions

I believe this is what is intended? It was not working for me like it was...