implemented parallelism through threads