Fixed thread concurrency issue