adding threading code - first cut