Updated with comment on how to solve concurrency problem