fix bug for on/off policy function