Fix hasGate function.