added improvied concurrency code