fixed duplicate threads

final logic change
simplified previous fix