foundations of multi-thread, better code