Modified to utilize interrupts properly.