implemented single state toggling with barriers