use select statments when writting to channels in a for loop. adds prote...

...ction against memory leaking if consumer thread dies