separate threads doesnt seem to run well; may have to check memory allocation.