fixed gate bug