added threading barrier