[¶ 1] Kerry Gray appeals from a judgment entered in the Superior Court (Androscoggin County, Gorman, J.) sentencing him to forty years imprisonment following his guilty pleas to attempted murder (Class A), 17-A M.R.S. §§ 152, 201 (2005); gross sexual assault (Class A), 17-A M.R.S. § 253(1)(A) (2005); and arson (Class A), 17-A M.R.S. § 802(1)(A) (2005). He argues that the court abused its discretion when it set the maximum sentence at forty years and when it declined to' suspend any portion of the sentence. He also contends that the sentence is excessive. We disagree with his contentions and affirm the judgment.
I. BACKGROUND
[¶ 2] Gray raped his seventy-six year old neighbor at knifepoint in her home. He also slit her throat and set fire to her house. After he was indicted for these offenses, Gray underwent examinations to assess his “competency, criminal responsibility, [and] abnormal condition of [the] mind,” as well as other issues related to his mental or emotional condition. 15 M.R.S. § 101-B (2005). Gray is a severely brain-damaged individual, who experienced several head traumas, including one in 1985 from a motor vehicle accident that left him in a coma for a month.
[¶ 3] Following a competency hearing, the court determined that Gray was competent to stand trial. Gray ultimately pleaded guilty to the charges of gross sexual assault, attempted murder, and arson, and the State dismissed another charge and agreed not to seek consecutive sentences.
[¶4] Two experts testified at the sentencing hearing. The State presented one of the psychologists who had participated in the competency evaluations. She testified that Gray told her that he cut the victim’s telephone lines so that she could not call for help and that he started the fire to distract anyone who would be looking for him. The psychologist opined that these actions demonstrated Gray’s ability to control his impulses. Another psychologist testified on Gray’s behalf about an alternative correctional program for brain-injured individuals like Gray, and why such a program was a better alternative than placement with the Department of Corrections.
[¶ 5] In announcing the sentence, the court began by explaining that it would determine the basic sentence, that is, the first step in the statutory sentencing process, 17-A M.R.S. § 1252-CG) (2005), on the gross sexual assault offense. The *614court stated that it considered the attempted murder to have been committed in order to facilitate the gross sexual assault and, under the circumstances of the offenses, it viewed the gross sexual assault as the worst of the three crimes. The court then described the details of the rape:
Keeping in mind that all rape involves some form of violence and violation, and contrary to the defendant’s assertions that his familiarity to [the victim] should have lessened her horror, it is difficult to imagine circumstances more horrifying than those presented by Mr. Gray’s actions. Mr. Gray told another neighbor that he fantasized about having sex with [the victim] and then went to her house to fulfill his fantasy. When she refused him, he wielded a knife to force her to submit. He dragged her upstairs to avoid being seen and then vaginally and anally raped the 76-year old woman he had known practically his whole life.
[The victim] did not submit easily. She fought back and as a result she was injured. The photographs presented by the State demonstrate some of her injuries and also give some indication of the duration of her suffering. [The victim’s] face, neck, torso and arms are covered with dry blood and bruises. There were blood stains on the bed clothes, on the telephone, and on various pieces of clothing that had been discarded.
Mr. Gray admitted to [the psychologist] that he punched [the victim] repeatedly during the attack and slit her throat as punishment because she wouldn’t play nice. Either before or after the rape he cut the telephone line to prevent her from calling for help. Given the relationship between Mr. Gray and his victim, the victim’s age and relative fragility, the degree of force used by Mr. Gray to compel her to submit to his will and to prevent her from calling the police and the multiple penetrations of her body, the Court finds that Mr. Gray’s actions compel a sentence substantially in excess of the twenty year limit generally allowed for Class A crimes.
The court set the basic sentence for the gross sexual assault at thirty-five years.1
[¶ 6] Next, the court looked at the mitigating and aggravating factors to arrive at the maximum sentence, which is the second step of the sentencing analysis. 17-A M.R.S. § 1252-C(2). The court considered that by pleading guilty Gray had expressed some remorse and had spared the victim from going through a trial.
[¶ 7] The court noted Gray’s argument that his brain damage should be seen as a mitigating factor. However, the court stated, “Mr. Gray’s deficits, although tragic, do not explain his behavior.” The court quoted from a portion of one of the competency examination reports, which referred to Gray’s head injury from the auto accident and other brain damage from additional traumas and years of substance abuse:
*615Mr. Gray has demonstrated in the past that he has the ability to refrain from acting on impulses which he knows are wrong or' substituting more acceptable outlets, thus he does have some capacity ■to control his behavior and is not as helpless as he would like others to believe.
The court concluded that Gray’s limitations did “not support the shortening of his sentence.”
[¶ 8] The court also looked at Gray’s 1998 conviction for unlawful sexual contact and his 2001 convictions for visual sexual aggression against a child and for sexual misconduct with a child under the age of fourteen. The court referred to other evaluation reports and recited from one stating that Gray suffered from “a wide array of mild impairments consistent with the sequelae of traumatic brain injury.” The court found that “the sequelae of traumatic brain injury” did not explain these prior convictions or the extent of his capacity for violence as demonstrated in the current offenses. The court stated:
All of the evaluators who have seen Mr. Gray agree he does have the ability to control his impulses and apply judgment. .. He admitted to [the psychologist] that he had been able to walk off other impulses to rape, yet he chose not to control his impulses here and committed a violent, heinous crime against a woman who had shown him nothing but kindness.
All of the information presented demonstrates clearly that Mr. Gray appreciated the wrongfulness of his actions and took steps to avoid being caught or stopped before, during or after the rape. Mr. Gray slit [the victim’s] throat either to compel her to submit to his will or to prevent her from escaping, or to keep her from reporting his crime to the police. Those actions have resulted in a conviction for the crime of attempted murder.
Then Mr. Gray set fire to [the victim’s] house while she was in it battered and bleeding. Those actions resulted in Mr. Gray’s conviction for the crime of arson. Because there has been no suggestion that consecutive sentences be imposed for those crimes, the Court has considered those actions as aggravating factors here.
In addition, Mr. Gray was still on probation for his last sexual crime at the time that he attacked [the victim]. The aggravating factors in this case also include the effect Mr. Gray’s actions have had on the victim and her family. [The victim] survived this attack entirely through her own courage and strength. However, in the effort she lost her ability to live independently[. P]erhaps more importantly, she lost the right to live free of fear.
[¶9] Finally, the court considered the risk that Gray presented to the public in light of the escalation of violence he had shown. The court stated that it was not satisfied that the program described by Gray’s expert witness could provide effective limits for ,the protection of the public. The court concluded that Gray’s actions warranted a maximum sentence of forty years.
[¶ 10] The third step of the sentencing analysis is a determination as to whether any portion of the maximum sentence should be suspended so that a period of probation may be imposed. 17-A M.R.S. § 1252-C(3). The court concluded that none of the forty years should be suspended. Because Gray had been on probation without success in the past, the court found that he was not a candidate for probation in the future. The lack of effective rehabilitation services both inside and outside of prison was one of the reasons *616the court gave for not imposing probation. The court concluded: “In summary, there is no effective way to protect society from Mr. Gray except to remove him from it.” The court then imposed concurrent sentences of seventeen years for attempted murder and twenty years for arson, giving its reasons for each of those sentences.
II. DISCUSSION
[¶ 11] Gray does not challenge the basic sentence set by the court in the first step of the sentencing process, which was thirty-five years.2 He challenges the maximum sentence of forty years and the refusal of the court to suspend any portion of the sentence. We apply the abuse of discretion standard both when reviewing the maximum sentence and when reviewing the court’s decision to not suspend any portion of the maximum sentence. State v. Sweet, 2000 ME 14, ¶15, 745 A.2d 368, 372-73. Gray further contends that the overall sentence is excessive, a contention we also review for an abuse of discretion. Id. ¶ 22, 745 A.2d at 375.
[¶ 12] Gray challenges the maximum sentence and the court’s analysis of the second step for two reasons.3 He contends that the court abused its discretion by failing to properly consider the mitigating factor of his brain damage, and he argues that the court “double counted” by referring to the same facts in the first and second steps of the analysis.
[¶ 13] The purpose of the second sentencing step is to allow the court to “appropriately individualize each sentence.” State v. Hewey, 622 A.2d 1151, 1154 (Me.1993) (quoting State v. Weir, 600 A.2d 1105, 1106 (Me.1991)). Mitigating factors may include those that demonstrate a low potential of reoffending, and aggravating factors may include those that demonstrate a high probability of reoffending. Id. The statute requires a court to consider, in setting the maximum sentence, “the effect of the offense on the victim.” 17-A M.R.S. § 1252-C(2). The objective factors concerning the impact of the crime on a victim are appropriate in the first step of the sentencing process, but the subjective factors of the impact are to be considered in the second step. See State v. Pfeil, 1998 ME 245, ¶ 16, 720 A.2d 573, 577. It is not an abuse of discretion for a court to refer to the same facts in the various steps of the sentencing analysis so long as the court is “weighing different considerations at each step.” State v. Shulikov, 1998 ME 111, ¶23, 712 A.2d 504, 511. We have said that it is an abuse of discretion for a court not to take into account any mitigating actions of the defendant that occurred immediately after the commission of the crime. See State v. MacDonald, 1998 ME 212, ¶ 19, 718 A.2d 195, 200.
[¶ 14] We do not agree with Gray’s contention that the court abused its discretion in failing to properly consider Gray’s mental condition. In Shulikov, 1998 ME *617111, ¶ 27, 712 A.2d at 511, we said it was not an abuse of discretion for the court to decline to address the defendant’s health issue:
The court did not address the state of Shulikov’s health in its sentencing order, however. While the court had the authority to take Shulikov’s health into account [citation omitted], it was not required to do so, and its implicit rejection of Shulikov’s bad health as a mitigating factor was within its discretion.
In this case the court did not ignore the fact of Gray’s condition. Instead, the court was not persuaded that his condition was sufficiently mitigating so as to either outweigh the aggravating factors or justify a reduction from the basic sentence.
[¶ 15] Gray also contends that the court abused its discretion by considering his conduct during the commission of the offenses in both the first and second steps of the sentencing process. He argues that it was appropriate for the court to analyze his actions in committing the offense when it considered “the particular nature and seriousness of the offense” in the first step, 17-A M.R.S. § 1252-C(1), but it was not appropriate for the court to consider those same actions again in the second step.
[¶ 16] Here, to the extent the court referred to the stabbing of the victim and the arson during its determination of the maximum sentence, it did so primarily in the context of describing Gray’s ability to control his impulses. The court responded to Gray’s argument that his brain injury should be considered as a mitigating factor by pointing to several of his deliberate acts during the commission of the offenses. The recitation of the facts of the offenses in more than one step of the sentencing analysis is not an abuse of discretion when it is done for a different purpose.
[¶ 17] Gray argues that the court abused its discretion when it stated that it considered the offenses of attempted murder and arson as aggravating factors to the gross sexual assault. We agree with Gray that if a court considers the facts of ancillary crimes committed with the primary crime to set a lengthy basic sentence on the primary crime, it should not use those identical facts as aggravating factors to add additional years to the basic sentence when arriving at the maximum sentence. We do not view the court’s sentencing analysis as having done that. When articulating its reasons for the basic sentence on the gross sexual assault, the court did not even mention the fire. It did state that Gray “wielded a knife to force her to submit,” but it was describing the compulsion element of the gross sexual assault crime. Although the court mentioned the blood shown in the photographs of the victim, it did so in the context of her resistance to the rape. The court did not mention the stab wounds or otherwise say anything about the attempted murder when it was describing the horrifies of the gross sexual assault. Therefore, because the court was not “double counting” the same facts for the same purposes in both steps of the sentencing analysis, it did not abuse its discretion.
[¶ 18] Gray further argues that the court abused its discretion in declining to suspend any portion of the maximum sentence. In the third step of the sentencing process it is appropriate for a court to consider the need to protect the public. See Pfeil, 1998 ME 245, ¶ 19, 720 A.2d at 578. The court explained that Gray’s history showed that he was not an appropriate candidate for probation and because there are no effective rehabilitation services available for him, “there is no effective way to protect society from Mr. Gray except to remove him from it.” The court *618was not persuaded by the testimony of Gray’s expert regarding a treatment program for individuals like Gray who have brain trauma. We cannot say that the court abused its discretion in refusing to suspend any portion of the sentence.
[¶ 19] Gray’s final argument is that the sentence is excessive. He contends that it is a de facto life sentence. He is in his mid-forties, and he argues that information presented at the hearing and in the reports demonstrates that his inability to control his impulses means that it is likely that he will not earn good time credits.
[¶ 20] We have held that it was not an abuse of discretion for a court to impose a forty-year sentence when the “sentence reflects the sentencing goals of restraining the convicted person in the interest of public safety as well as recognizing the gravity of the offenses.” Sweet, 2000 ME 14, ¶24, 745 A.2d at 375. In Sweet we held that a sixty-five-year sentence was not an abuse of discretion although it meant that the defendant would not be released until he was in his eighties, and it was unusually lengthy in comparison to other Maine sentences.4 Id. ¶ 33, 745 A.2d at 376. There we found that the court did not abuse its discretion because of the “multiple aggravating factors,” which included the unlikelihood of rehabilitation. Id. ¶¶ 31, 33, 745 A.2d at 376. In this case, there are also multiple aggravating factors, which include the prognosis that rehabilitation is unlikely; Gray’s escalation of violence, and his history. Furthermore, the sentencing court demonstrated that it was taking into consideration all of the sentencing goals, including public safety and the gravity of the offenses. In light of our precedent, we cannot conclude that the court abused its discretion in the overall length of the sentence.
The entry is:
Judgment affirmed.
. At the time the offense was committed, the sentencing statute was 17-A M.R.S.A. § 1252(2)(A) (Supp.2003), which allowed a sentence of forty years:
In the case of a Class A crime, the court shall set a definite period not to exceed 40 years. The court may consider a serious criminal history of the defendant and impose a maximum period of incarceration in excess of 20 years based on either the nature and seriousness of the crime alone or on the nature and seriousness of the crime coupled with the serious criminal history of the defendant.
Section 1252(2)(A) was amended by P.L.2003, ch. 657, § 10 (effective July 30, 2004) (codified at 17-A M.R.S. § 1252(2)(A) (2005)) to provide: "In the case of a Class A crime, the court shall set a definite period not to exceed 30 years.”
. One of Gray’s issues on appeal initially was whether the sentence violated his Sixth Amendment right to a jury trial because it was in excess of twenty years. See State v. Schofield., 2005 ME 82, ¶21, 876 A.2d 43, 49-50. However, Gray has withdrawn that issue from appeal.
. The sentencing statute describes the second step as follows:
2. The court shall next determine the maximum period of imprisonment to be imposed by considering all other relevant sentencing factors, both aggravating and mitigating, appropriate to that case. These sentencing factors include, but are not limited to, the character of the offender and the offender’s criminal history, the effect of the offense on the victim and the protection of the public interest.
17-A M.R.S. § 1252-C(2).
. In State v. Sweet, 2000 ME 14, 745 A.2d 368, the two defendants both appealed their sentences. We affirmed the consecutive sentences totaling forty years imposed on Sweet and totaling sixty-five years on Poulin. Id. ¶¶ 1, 19, 745 A.2d at 370, 374.