refactor interrupt handling