sketch cleaned up and tested on two arduinos