brian's version with two threads running at the same time, working some of the time and some of the time giving undefined errors