fixed threading, still has counting issue