fix multiple begin bug