threading and looping
nicer looping, now threaded if optimal