Add multi thread support