Fix ag detection