CheckFlag function.