Added PI loop