Added functionality to add threads