added some gadget2 code