Adding A.P. gain loop