Working version, one concurrency bug remains