fix gate bug