updated thread architecture

now easy to change the number of threads