implemented multi-thread support