Complete, functional code

Sans idle state printout