removed depedency of threads
Now works on any number of process