Added loop for threads