checking and transforming gadgets to meet the desired form