rewrite of the amazon irq code