refactored to use both timers, interrupts and sleep mode