finished exception logic and Gateoutput prepare