
261 N.W.2d 650 (1977)
STATE of North Dakota, Plaintiff and Appellee,
v.
Bernard S. PIPER, Defendant and Appellant.
Cr. No. 608.
Supreme Court of North Dakota.
December 19, 1977.
Rehearing Denied January 19, 1978.
*652 Robert P. Bennett, Asst. State's Atty., Bismarck, for plaintiff and appellee.
Daniel J. Chapman, Bismarck, for defendant and appellant.
SAND, Justice.
The defendant, Bernard S. Piper, appealed from a judgment of conviction of attempted sexual imposition and from an order denying his motion for a new trial.
On 17 June 1976, the defendant was charged with the crime of attempted sexual imposition under §§ 12.1-20-04, 12.1-06-01(1), 12.1-06-01(3), and 12.1-32-01(3) of the North Dakota Century Code.
The complainant, Ronda, testified that on 16 June 1976 she left the party at the apartment, went to her bedroom to lie down because she had to go to work the next day, and went to sleep. According to her testimony, she was later awakened because "somebody was standing there trying to take my clothes off." She also testified that the defendant took off all her clothes and then removed his pants. She said that during this time she was fighting him and screaming for help. According to her testimony, the defendant told her to shut up and threatened to hit her four or five times. She said that the defendant sat on top of her, that he tried to put her legs on his shoulders and that he attempted intercourse with her. Ronda testified that when her roommate, Pauline, opened the door of the bedroom, she screamed and "asked her to help me and to get him out of there." The roommate went to the neighbors for help and also summoned the police, who arrived before the defendant left the apartment.
The defendant's testimony conflicted sharply with the testimony of the complaining witness. He testified that earlier, during the evening of 16 June 1976, he had consumed several six-packs of beer and some gin before deciding to go to "Paula's" apartment for more beer. Upon his arrival at the apartment shared by Pauline and the complainant, Ronda, he found the door open and entered the apartment. According to his testimony, he had attended a beer party several weeks earlier at this apartment and had been invited to return.
The defendant testified that he walked through the apartment, observed a beer keg and liquor bottles in the kitchen, and then entered the bedroom, where he saw Ronda, fully clothed, asleep on the bed. He sat on the bed, Ronda awoke, and mistaking him for her boyfriend, "Wayne," made amorous advances toward him. Defendant said he left to get a beer in the kitchen and returned to find the complainant unclothed on the bed and calling him "Wayne."
Defendant admitted that he "made out with" [kissed] Ronda and "touched her," including her breasts, before she discovered that he was not "Wayne," her boyfriend. The defendant denied removing Ronda's clothing, or being between her legs or sitting on her chest or stomach. He testified that after Ronda discovered he was not "Wayne," they were talking and he was trying to identify himself to her when the roommate, Pauline, opened the door.
The jury found the defendant guilty of attempted sexual imposition on 4 February 1977, and judgment of conviction was entered on 9 March 1977. The defendant appealed. He contends that he was denied a fair trial for the following reasons:
1. Refusal of the trial court to instruct on the requested lesser included offense of sexual assault;

*653 2. Refusal of the trial court to allow inquiry into the complainant's sexual relationship with her boyfriend, when the defense was mistaken identity for her boyfriend;
3. Alleged misconduct of the assistant state's attorney in statements made on closing argument;
4. Vague and indefinite jury instructions;
5. Failure of the court to grant a judgment of acquittal under Rule 29(a), North Dakota Rules of Criminal Procedure.
We will first consider the defendant's contention that the trial court erred by refusing to instruct the jury on the lesser included offense of sexual assault. The defendant was charged with the crime of attempted sexual imposition under §§ 12.1-20-04, 12.1-06-01(1), 12.1-06-01(3), and 12.1-32-01(3) of the NDCC. We note at the outset that the crimes of sexual imposition and sexual assault, set out in §§ 12.1-20-04 and 12.1-20-07, NDCC, respectively, have been amended by the 1977 Legislature. See S.L.1977, ch. 122, § 3 and § 5. The issue, therefore, is limited to an interpretation of these two statutes as they existed at the time of the alleged commission of the offense and the trial, which were prior to the amendments.
This Court has previously held that the defendant must have first requested the trial court to instruct the jury on any lesser included offenses before he may specifically raise it on appeal as reversible error. State v. Champagne, 198 N.W.2d 218, 227 (N.D. 1972). In the instant case, a jury instruction on sexual assault was requested and denied by the court:
"Well, the Court believing that the elements of the offense are totally different in this case and that the requirement of the charge as made by the State does not  this is not necessarily and especially in this case a lesser included offense and even the Court believes that the testimony of the defendant himself refutes the very instruction, will deny the instruction and as to entering it on the record and according to the record the instruction is automatically excepted and the rights of appeal are reserved in that manner."
This Court, on at least two occasions, has approvingly applied the independent evidence test to determine if a jury instruction on a lesser included offense is required. See State v. Tucker, 58 N.D. 82, 224 N.W. 878, 884 (1929); State v. Ankney, 195 N.W.2d 547 (N.D.1972). We have stated that
". . . it is not error to fail to instruct on the lesser offense when there is no evidence which would tend to reduce the offense. . . ." Ankney, supra at 554.
In Ankney, the Court determined that the evidence supported a finding that the defendant was guilty of burglary and that there was no evidence to indicate a lesser offense was involved.
In the instant case, the defendant argues that sexual assault is a lesser included offense of attempted sexual imposition, and the trial court's failure to instruct accordingly constituted reversible error. Although Rule 31(c) of the North Dakota Rules of Criminal Procedure (on the assumption appropriate instructions have been given) permits the conviction of a defendant on a lesser offense, we note that there is no constitutional right guaranteeing a defendant a jury instruction on a lesser included offense. In Keeble v. United States, 412 U.S. 205, 213, 93 S.Ct. 1993, 1998, 36 L.Ed.2d 844 (1973), the United States Supreme Court said:
". . . we have never explicitly held that the Due Process Clause of the Fifth Amendment guarantees the right of a defendant to have the jury instructed on a lesser included offense . . . ."
It also said, at page 208, 93 S.Ct. at page 1995:
". . . the defendant is entitled to an instruction on a lesser included offense if the evidence would permit a jury rationally to find him guilty of the lesser offense and acquit him of the greater."
North Dakota's independent evidence test is compatible with this test.
*654 We are not persuaded by defendant's eloquent argument which in effect would require giving the lesser included offense of sexual assault instructions in every charge of sexual imposition or attempted sexual imposition. We are not satisfied that justice will be done if instructions on the lesser included offense are given regardless of the evidence because it may well lead the jury to a compromise decision, which is not compatible with the function of the jury in a criminal case.
The Supreme Court of the State of Wisconsin, in Hughes v. State, 55 Wis.2d 477, 198 N.W.2d 348, 350 (1970), stated:
"The early cases point out and emphasize and we must stress again, because the question keeps recurring, that a determination of whether an instruction on a lesser included crime should be given to a jury is not solved by merely determining the crime charged includes the lesser offense because juries are not to be given the discretion or freedom to pick and choose what offense the accused should be found guilty of. [Citation omitted.] The evidence must throw doubt upon the greater offense. Juries cannot rightly convict of the lesser offense merely from sympathy or for the purpose of reaching an agreement. They are bound by the evidence and should be limited to those included crimes which a reasonable view of the evidence will sustain and does not convince beyond a reasonable doubt the additional element of the greater crime existed." [State v. Melvin, 49 Wis.2d 246, 253, 181 N.W.2d 490, 494 (1970).]
If the test were only whether or not the lesser included offense[1] must necessarily have been committed before or in the commission of the greater offense, assault and battery would also be a lesser included offense in the crime of assault with intent to murder, or murder where physical contact occurred.
The test is not merely whether or not the offense is a lesser included offense of the basic offense charged, but rather is whether or not there is evidence which will create a reasonable doubt as to the greater offense and support a conviction of the lesser included offense. The "beyond a reasonable doubt" test also applies to the lesser included offense.
If the defendant's testimony were accepted and believed, there would be no attempted sexual imposition. Neither would there be a sexual assault because defendant testified that the complainant made advances to him, mistaking him for her boyfriend, "Wayne." Defendant's testimony, if believed, supports an acquittal of both attempted sexual imposition and sexual assault, but not a conviction of the lesser offense of sexual assault, which prior to amendment required that the person knowingly have sexual contact with another when "he knows that the contact is offensive to the other person." § 12.1-20-07(1), NDCC. In the instant case, where the defendant testified that the complainant invited the sexual contact, the jury could not logically find as a fact that the defendant knew the sexual contact was offensive to the complainant. Had the jury believed the defendant, it necessarily would have had to enter a verdict of innocent. Even if the jury believed only a (material) part of the complainant's testimony and a (material) part of the defendant's testimony, the evidence would not be legally sufficient to support a conviction of sexual assault.[2]
In State v. Bradley, 254 Iowa 211, 116 N.W.2d 439 (1962), the Iowa Supreme Court held that failure to instruct on a lesser included offense is not prejudicial *655 error unless the included offense is necessarily included in the offense charged, and the record contains evidence justifying a finding of such included charge rather than the greater offense. The Court, finding no error, in Bradley, supra, at 445, stated:
"If the state's evidence was to be believed, the assault was a vicious and brutal one from which no conclusion could well be reached but that there was present an intent to inflict great bodily harm upon Enderson. If the defendant's version was to be accepted there was not even so much as an assault, much less an assault and battery."
We likewise find that if the defendant's testimony is to be believed, there was no sexual assault, much less an attempted sexual imposition.
We now turn to defendant's second contention that the trial court erred in refusing to allow inquiry into the complainant's sexual relationship with her boyfriend, when the defense was mistaken identity of defendant for her boyfriend. Defendant, in his motion for a new trial, claim that:
". . . in view of the allegation of the Defendant that the complaining witness invited `Wayne' to have sexual relations with her, which would be a bearing upon the `consent' of the complaining witness and which, while it would not constitute consent to have intercourse with the Defendant, [it] would be material to the Defendant's contention that he desisted as soon as the complaining witness ascertained that he was not her boyfriend and would, therefore, negate the existence of the necessary intent to constitute an offense under the charge of sexual imposition."
Section 12.1-20-14, NDCC, makes inadmissible evidence of specific instances of the complaining witness' sexual conduct to prove consent in prosecutions for violation of §§ 12.1-20-03 or 12.1-20-04, NDCC, or attempts to commit an offense defined in these sections. Therefore, § 12.1-20-14 applies to the crime of attempted sexual imposition. However, § 12.1-20-15, NDCC, permits a defendant to attack the credibility of the complaining witness with evidence of sexual conduct by following certain procedures, and therefore defendant's contention that § 12.1-20-14 unconstitutionally deprives him of a defense is unwarranted.
Section 12.1-20-15, NDCC, sets out the mandatory preliminary procedures which must be followed before evidence of complaining witness' sexual conduct is permitted to be offered to attack the credibility of the complaining witness. As a prerequisite for offering such evidence, the defendant must first make and file with the court, and serve upon the prosecuting attorney, a written motion accompanied by an affidavit in which the offer of proof of the relevancy of the evidence of the sexual conduct of the complaining witness is made as well as its relevancy in attacking the credibility of the complaining witness. At this point, should the court find the offer of proof sufficient, a hearing out of the presence of the jury is held at which the defendant is permitted to question the complaining witness regarding the offer of proof. The defendant did not comply with the procedures outlined in § 12.1-20-15, NDCC. The record contains no written motion or affidavit. In the absence of such a record demonstrating defendant's compliance with § 12.1-20-15, NDCC, we reject defendant's contention on this evidentiary issue.
We now consider the contention that the defendant was denied a fair trial because of statements made by the assistant state's attorney on closing argument. The statement at issue follows:
"If you believe the defendant's testimony you are almost going to have to find that . . . [Ronda] is a tramp by doing what the defendant said she did."
The transcript of the trial and the proceedings support the assistant state's attorney's contention that his statements on closing argument were made in response to the defense attorney's attacks on Ronda's credibility. On closing argument, the defendant attorney made the following statement:
"There was no reason for her to have told an untruth or to have exaggerated the *656 story or, is there a reason and that is to defend the appearance of her own morality? To have told a story then that would justify the fact that when Pauline . . came into the bedroom that she was in the bedroom naked with another man?"
We believe the remarks of both the assistant state's attorney and the defense attorney, as set out above, were improvidently made, but do not constitute reversible error. The defense attorney argued in closing that Ronda lied in her testimony to the court, and improperly speculated that her motive for lying was to protect her reputation, which was never an issue in the trial. No evidence was presented during the state's case-in-chief relating to her morality or chastity. The assistant state's attorney's response to defense counsel's attack on complainant's credibility was also an improper inference drawn from the testimony. However, even though the statements of the assistant state's attorney may be improper, they do not constitute reversible error when made in response to remarks of defense counsel. See State v. Gibson, 69 N.D. 70, 284 N.W. 209 (1938); State v. Gulke, 76 N.D. 653, 38 N.W.2d 722 (1949); People v. Pomranky, 62 Mich.App. 304, 233 N.W.2d 263, 266 (1975); People v. Meir, 67 Mich.App. 534, 241 N.W.2d 280, 281 (1976). See also, 23A C.J.S. Criminal Law § 1090, p. 128; and 24A C.J.S. Criminal Law § 1902(1), p. 995.
We point out that any prejudicial effect caused by the assistant state's attorney's remarks was cured by the court in its instructions to the jury. The record shows that the court instructed the jury that "The opening statements and closing arguments of counsel are intended to help you in understanding the evidence, applying the law, and in determining the facts; but they are not evidence." We note that because defense counsel waited until after the assistant state's attorney had completed his closing argument before objecting to his remarks, the trial court had no opportunity to immediately instruct the jury to disregard his improper remarks. The appropriate place for the defense counsel to raise an objection was at the time the improper remarks were made, which was during the closing argument. See State v. Braathen, 77 N.D. 309, 43 N.W.2d 202 (1950).
Therefore, in the light of the court's curative jury instruction and viewing the state's attorney's remarks in the context in which they were made and the facts and circumstances of the proceedings generally [see State v. Gibson, supra] we cannot say that defendant was unduly prejudiced by the improper comments made.
The defendant has also asserted that he was denied a fair trial because of vague and indefinite jury instructions regarding the essential elements of the offense. The record demonstrates that the trial court instructed the jury as to the essential elements of attempted sexual imposition, namely that the defendant did attempt to engage in a sexual act with the complainant; that the defendant did make a threat to her that would render a person of reasonable firmness incapable of resisting to compel her to submit to a sexual act; that the defendant and the complainant were not married; and that the defendant did intentionally engage in conduct which, in fact, constituted a substantial step toward the commission of the offense.
The Court has held that in determining whether a jury instruction is misleading, the instruction as a whole must be considered. See State v. Erickson, 241 N.W.2d 854, 861 (N.D.1976); State v. Steele, 211 N.W.2d 855 (N.D.1973). In State v. Williams, 150 N.W.2d 844 (N.D.1967), we stated that the instructions must be considered as a whole and when, as a whole, they correctly advise the jury as to the law, the instructions are sufficient although a portion alone may be insufficient or erroneous. We have determined in this case that the jury instructions regarding the essential elements of the offense, taken as a whole, are clear and are not misleading.
We now consider defendant's final contention that the trial court erred in failing to enter a judgment of acquittal under Rule 29(a), North Dakota Rules of *657 Criminal Procedure. In reviewing the record we have determined that there was sufficient evidence from which the jury could find the defendant guilty of the offense charged. Strong arguments were presented by defendant pertaining to the weight to be given to the testimony. It is the jury's function to weigh the evidence, not ours, and neither this Court nor the trial court can substitute its judgment for that of the jury when there is sufficient evidence to support a conviction.
For the reasons stated earlier herein, we affirm the trial court's judgment of conviction of attempted sexual imposition and its order denying defendant's motion for a new trial.
ERICKSTAD, C. J., and PAULSON, PEDERSON and VOGEL, JJ., concur.
NOTES
[1]  The Ninth Circuit Court of Appeals, in Giles v. United States, 144 F.2d 860, 861 (1944), defined lesser included offense as: "To be necessarily included in the greater offense the lesser must be such that it is impossible to commit the greater without first having committed the lesser."
[2]  In State v. Hicks, 241 N.C. 156, 84 S.E.2d 545, 547 (1954), involving a common law robbery, the Court said, "Mere contention that the jury might accept the State's evidence in part and might reject it in part will not suffice" the giving of the lesser included offense instruction of assault with a deadly weapon. We, however, follow the "independent evidence" rule.
