added threads
added threaded code