improve threading performance