Adding multi threads support