added some code handling interrupts