Modified code: Threads working Properly