Move ag statements into if case