finished refactoring to include interrupts