Once the prosecutor offered up the forbidden fruit of improperly admitted evidence, defense counsel chomped into it with relish. At issue is the propriety of the judge’s attempt to minimize the damage.
Following trial in District Court, a jury found the defendant guilty of indecent assault and battery on a person over fourteen years of age.1 On appeal, the defendant argues that (1) the judge *254erred in not allowing defense counsel to reference testimony concerning the victim’s prior sexual conduct in his closing argument; (2) the evidence was insufficient to permit an instruction about the victim’s incapacity to consent; and (3) the judge’s use of the word “unconscious” in the jury instructions on the element of consent was improper.2
As the judge acted within her discretion to exclude reference to the prejudicial testimony that would have been inadmissible under the rape shield law, G. L. c. 233, § 21B, we affirm.
Facts. On March 16, 2007, after a night of drinking together at a bar called the Poirier Post, the defendant sexually assaulted the victim, a thirty-two year old resident of New Bedford. After the victim reported the assault, the defendant was arrested and charged with one count of aggravated rape, G. L. c. 265, § 22(a), and one count of sodomy, G. L. c. 272, § 34. These charges were reduced to two counts of indecent assault and battery on a person over fourteen years of age, G. L. c. 265, § 13H.3
The theory of the Commonwealth was that the defendant planned in advance to sexually assault the victim, who was a friend of his girl friend, Laurie. Throughout the course of the evening, in the presence of Laurie, the defendant put his arm around the victim and touched her hair and legs on numerous occasions. When she told him not to touch her, the defendant responded, “it’s okay, Laurie doesn’t mind.” While playing pool at the bar, the defendant twice rubbed his groin area up against the victim’s “back and [her] butt.” When the victim again told the defendant not to touch her, he responded, “I like it when you’re feisty.”
Laurie and the defendant bought the victim multiple drinks, and she had approximately “four or five drinks [and a] couple of shots” that night. The victim testified that while she had been at the bar previously with the defendant, he did not normally buy her drinks.
Following a conversation in the bathroom with Laurie, the victim told another patron of the bar that she did not feel comfortable leaving with the defendant and Laurie.4 She testified *255that at the time she felt “[v]ery groggy” and “heavy” and went to the bathroom again and put cold water on her face. She testified, “I wasn’t sure why I wasn’t feeling right,” indicating that she felt “[v]ery disoriented. Sort of dizzy. Not like I normally would have on a Friday night with . . . just the alcohol.”
The victim then testified that, after leaving the bathroom, the next thing she remembered was “being in the back of Laurie’s car,” driven by the defendant; she realized that they were driving to the house of Laurie or the defendant rather than her own. The victim did not remember leaving the bar, and in the car, she “begged them to take me home.”5
The victim next remembered “waking up cold and naked with my own vomit all over me, with a deer head hanging over my head.” She called out for Laurie, feeling “dizzy” and “heavy” in a way she had never felt before, explaining that her body “was like jello.” She testified, “I knew that I had been raped. ... I was tom and I was bmised and I was shaking.” She had bruises on her hips, which “looked like they had been someone’s hand prints holding me, making me stay.” When she found Laurie in the house, the victim testified that Laurie did not seem at all surprised to see her standing naked in her condition. Laurie brought her to the bathroom, where the victim observed “a sink filled with . . . dildos and . . . vibrators” that were wet. While in the shower, the victim was “still feeling horribly . . . groggy and sore. So, so sore ... my vaginal area was in so much pain ... [as well as] my mouth. My anus.”
At trial, the Commonwealth called Craig Lincoln, the bartender at the Poirier Post on the night of the assault. On cross-examination, when asked by defense counsel to describe the interaction between the defendant and the victim at the bar, Lincoln testified that “[i]t seemed flirtatious. But that was just the way [the victim] was anyways.” On redirect, the prosecutor asked Lincoln to clarify what he meant by describing the victim as a flirtatious person, and Lincoln testified that “[s]he seemed *256to be very flirtatious with a lot of people . . . myself included .... She made advancements at me a few times . . . she would always come to the comer of the bar and ask me to go in the back room with her.”
On recross, defense counsel asked Lincoln to expand on his testimony regarding the victim’s advances, and Lincoln testified, “[s]he asked me to go in the back room [for] sexual favors . . . she said that she would give me a blow job.” Lincoln further testified that this had happened “three or four times” within a period of six months and that, on one occasion, “she came up behind me into the back room and said there’s nobody here, um, let’s just do it.” Inexplicably, the prosecutor did nothing (other than initially delve into the area).6
Lincoln’s testimony went unaddressed until the jury charge conference, wherein the prosecutor stated, “I think I made a mistake in the course of Mr. Lincoln’s . . . testimony, when . . . he testified that the victim propositioned him for sex and offered to give him blow jobs.” The prosecutor then opined that the evidence was improperly admitted and that an objection should have been lodged, and requested that the judge instruct defense counsel not to reference the testimony in closing argument. In response, the judge replied that the testimony “would’ve been inadmissible under [the] rape shield [statute],” but allowed defense counsel time to evaluate whether there was any basis to allow reference to it.
Following the break, defense counsel declined to further address the issue, and the judge forbade both counsel from referring to the evidence, finding that “its prejudicial [ejffect outweighs its probative value and in looking at the statute, that is a determination for the judges to make [sz'c] and I’m making that determination.” She further noted, “I understand it came in without objection but I don’t think that that then removes . . . the prohibition of such evidence under the statute. And I don’t want to compound what I view really as an error by allowing *257argument relative to that evidence.” When the prosecutor asked whether she would be “permitted to attempt to rehabilitate with respect to those statements” in her closing argument, the judge stated, “frankly, I don’t think it’s something that should’ve come out and I don’t even want it even . . . highlighted.”
On appeal, the defendant argues that since the testimony concerning the victim’s prior sexual conduct was elicited spontaneously and without objection by the Commonwealth, defense counsel should have been able to use the testimony in his closing to impeach the victim. He suggests that the Commonwealth’s failure to object and the judge’s failure to strike the testimony indicated that the testimony was not prejudicial, and that, once it was elicited, he should have been allowed to argue it.
Discussion. We need not belabor the point that the evidence was introduced in contravention of the rape shield statute.7 At issue is the broader question of how a judge may react when improper evidence is introduced.
“The judge’s function at any trial is to be ‘the directing and controlling mind at the trial, and not a mere functionary to preserve order and lend ceremonial dignity to the proceedings.’ ” Commonwealth v. Sapoznik, 28 Mass. App. Ct. 236, 241 n.4 (1990), quoting from Commonwealth v. Wilson, 381 Mass. 90, 118 (1980). “At times during the course of any trial ... it may become necessary for a judge to intervene although there has been no objection to the admissibility of certain evidence . . . [and] the judge is not required to sit idly by while counsel for either side questions a witness in an effort to obtain an answer which could be the basis of either a motion for mistrial or a claim on appeal that prejudicial matters were brought to the attention of the jurors.” Ibid. See generally Mass. G. Evid. § 611.
*258Lincoln’s testimony concerning the victim’s prior sexual conduct was inadmissible. Ideally, there should have been immediate action on the part of the prosecutor or the judge sua sponte when the line was crossed.8 Regardless, the damage having been done, the judge acted within her discretion to prevent a further violation by precluding any reference by either side to the improper testimony in the closing arguments.9
Conclusion. As the judge acted within her discretion in prohibiting reference to testimony concerning the victim’s prior sexual conduct, no error was committed.
Judgment affirmed.
The first count, on which the defendant was found guilty, alleged that the defendant touched the vagina of the victim with his penis. The defendant was found not guilty on a second count, touching the victim’s anus with his penis. We note that the defendant’s deoxyribonucleic acid (DNA) profile matched the DNA profile of sperm cells taken from the victim’s vagina, but no sperm cells were recovered from her anus.
In light of the facts that are described in detail below, the two latter arguments are insubstantial. No more need be said.
We were informed at oral argument that the charges were reduced to allow the District Court to retain jurisdiction over the matter.
The victim was prepared to testify that the reason for her discomfort was *255the conversation she had with Laurie in the bathroom in which Laurie asked the victim to have sex with the defendant. The judge ruled this statement was hearsay and did not allow its introduction. We offer no comment on the propriety of the ruling.
A defense motion in limine, see Mass. G. Evid. § 103(a)(3) (2010), was allowed, prohibiting the victim from testifying that she thought she had been drugged.
This is surprising given that prior to trial, the judge allowed the Commonwealth’s motion in limine to exclude reference to any alleged sexual activity with individuals other than the defendant. Though the transcript is not completely clear, defense counsel indicated that he did not intend to offer any such evidence, and appeared to acknowledge that it would not be admissible “[ujnder rape shield [statute].”
Under G. L. c. 233, § 21B, inserted by St. 1977, c. 110, “[e]vidence of specific instances of a victim’s sexual conduct . . . shall not be admissible except evidence of the victim’s sexual conduct with the defendant or evidence of recent conduct of the victim alleged to be the cause of any physical feature, characteristic, or condition of the victim; provided, however, that such evidence shall be admissible only after an in camera hearing on a written motion for admission of same and an offer of proof. If, after said hearing, the court finds that the weight and relevancy of said evidence is sufficient to outweigh its prejudicial effect to the victim, the evidence shall be admitted; otherwise not.” See Mass. G. Evid. § 412.
We note that all parties — the judge, prosecutor, and defense counsel — share a responsibility in such situations. Ordinarily, a judge need not intervene sua sponte. However, he or she is well advised to at least request a sidebar when a well known statutory law is seemingly being violated.
It matters not that the testimony was not struck from the record and the jury instructed to disregard it. In other contexts, cases have observed that sometimes it may be preferable to refrain from drawing attention to prejudicial evidence as opposed to striking it. See Commonwealth v. DelValle, 443 Mass. 782, 791 n.11 (2005) (“the less said the better”); Commonwealth v. Anderson, 58 Mass. App. Ct. 117, 126 (2003) (“more harm than good”). It was within the judge’s discretion to handle the situation as she did. Indeed, in this situation, the judge may well have had the discretion to strike the evidence, even at this late stage of the trial.