Using lock for each id