Still trying to fix the flag bug