fix a bug in barrier