Start of gate check code