always insert blocks into function when generating code.
use moveAfter to make sure the blocks are in a sane order.