
915 So.2d 557 (2005)
Anna PONTIUS, individually and as personal representative of the estate of Andrew L. Pontius, Jr.
v.
STATE FARM MUTUAL AUTOMOBILE INSURANCE COMPANY.
No. 1030974.
Supreme Court of Alabama.
June 3, 2005.
*559 Rhonda Marie, Hoover, for appellant.
Bert S. Nettles, C. Dennis Hughes, and Khristi J. Doss of Haskell Slaughter Young & Rediker, LLC, Birmingham, for appellee.
BOLIN, Justice.[1]
Anna Pontius, individually and as personal representative of the estate of Andrew L. Pontius, Jr., appeals from the dismissal of her bad-faith and breach-of-contract claims against State Farm Mutual Automobile Insurance Company ("State Farm").
On October 18, 2002, Anna and her husband, Andrew L. Pontius, Jr., were involved in an automobile accident; Celia Martin, a minor, was the driver of the other vehicle. On October 28, 2002, the Pontiuses sued Martin and her parents, Paul and Denise Martin (hereinafter referred to collectively as "the Martins"). The Martins answered, denying all liability and asserting contributory negligence as an affirmative defense. The Pontiuses' automobile was insured with State Farm, and they subsequently made a claim for underinsured-motorist ("UIM") benefits under their insurance policy. State Farm did not pay the benefits.
On February 13, 2003, State Farm moved to intervene in the pending action between the Pontiuses and the Martins, acknowledging that its insurance policies with the Pontiuses provided for UIM coverage and stating that the disposition of the action might, as a practical matter, impair or impede State Farm's ability to protect its interest. On March 7, 2003, the trial court granted State Farm's motion to intervene.
On May 23, 2003, the Pontiuses amended their complaint to add State Farm as a *560 defendant and asserted claims seeking UIM benefits and alleging breach of contract and bad-faith refusal to pay an insurance claim. On June 22, 2003, State Farm filed an answer to the amended complaint, denying the material allegations. In its answer, State Farm affirmatively pleaded the defense of failure to state a claim. That same day, State Farm filed a motion for a dismissal of the breach-of-contract and bad-faith-failure-to-pay claims against it pursuant to Rule 12(b)(6), Ala. R. Civ. P., or for a judgment on the pleadings on those claims pursuant to Rule 12(c), Ala. R. Civ. P. On July 2, 2003, Andrew died as a result of the injuries he sustained in the automobile accident.[2]
On August 6, 2003, the trial court held a hearing on State Farm's motion for a dismissal or a judgment on the pleadings. On August 12, 2003, the trial court denied State Farm's motion. State Farm then filed a motion entitled a "Motion to Reconsider Order Entered August 12, 2003," supported by a supplemental brief.
Following another hearing, the trial court entered an order on October 13, 2003, granting State Farm's motion for a dismissal and for a judgment on the pleadings, under both Rule 12(b)(6), Ala. R. Civ. P., and Rule 12(c), Ala. R. Civ. P., with regard to Pontius's breach-of-contract and bad-faith-failure-to-pay claims. Subsequently, Pontius and State Farm resolved the UIM claim, and on January 20, 2004, the trial court dismissed the UIM claim with prejudice. Pontius also resolved the pending claims against the Martins. On February 11, 2004, the trial court entered an order dismissing the case. On March 23, 2004, Pontius appealed the trial court's order dismissing the breach-of-contract and bad-faith-failure-to-pay claims against State Farm.
In seeking the dismissal in the trial court, State Farm argued that there can be no action against it based on an alleged breach of contract or the tort of bad-faith failure to pay an insurance claim until Pontius demonstrated that she was legally entitled to recover damages from the underinsured motorist, Celia Martin. In its motion to dismiss, State Farm asserted that Pontius's allegations in the amended complaint adding State Farm as a defendant that the injuries and damage were caused by an underinsured motorist "demonstrates on the face of the amended complaint that plaintiff['s] breach of contract and bad faith claims are not ripe for adjudication." State Farm stated in its motion to dismiss, in pertinent part:
"3. Before it can be determined whether [Pontius has] stated a claim of breach of contract or bad faith against State Farm for the alleged non-payment of UIM benefits, it must first be determined that [Pontius `is] legally entitled to recover' as that language is used both in the State Farm contract and in the Alabama Uninsured Motorist Act. LeFevre v. Westberry, 590 So.2d 154, 157 (Ala.1991). To be `legally entitled to recover as damages' the insured must establish fault on the part of the uninsured motorist, which gives rise to damages, and must then prove the extent of those damages. Id. (Citing Quick v. State Farm Mut. Auto. Ins. Co., 429 So.2d 1033, 1035 (Ala.1983)).
"4. It is the insured's obligation to satisfy all contractual conditions precedent to coverage before bringing a claim for breach of the insurance contract. Nationwide Ins. Co. v. Nilsen, 745 So.2d *561 264, 267 (Ala.1998). Consequently, in the context of uninsured motorist coverage, the Supreme Court of Alabama has consistently held, `[T]here can be no breach of a an uninsured motorist contract, and therefore no bad faith, until the insured proves that he is legally entitled to recover.' LeFevre, 590 So.2d at 158 (quoting Quick, 429 So.2d at 1035). Thus, in LeFevre the Court instructed that a delay in payment of UIM benefits does not constitute bad faith if there is a bona fide dispute concerning either liability or damages. Id. at 161. Moreover, the Court in LeFevre held that `the insurer and the insured occupy adverse positions until the uninsured motorist's liability is fixed; therefore there can be no action based on the tort of bad faith based on conduct arising prior to that time, only for subsequent bad faith conduct.' Id. at 159 (emphasis added); see also Bowers v. State Farm Mut. Auto. Ins. Co., 460 So.2d 1288, 1290 (Ala.1984)(`[W]here a legitimate dispute exists as to liability, whether under primary coverage or uninsured motorist coverage, a tort action for bad faith refusal to pay a contractual claim will not lie.' (emphasis added)).
"5. [Pontius's] complaint and amended complaint raise claims that are legally self-defeating. Through the very same lawsuit in which [she is] attempting to establish the fault of the Martin defendants and the amount of [her] allegedly resulting damages, [Pontius] now [is] also alleging that State Farm committed a breach of the insurance contract and the tort of bad faith with regard to [her] UIM coverage. As noted above, throughout their pre-suit contentions and their pleadings in this action the Martin defendants have disputed and continue to dispute that they are legally at fault for the accident or any damages arising from the accident. Thus, State Farm cannot legitimately be charged with a breach of contract of insurance (Court Five) or of a bad faith refusal to pay UIM benefits (Count Six) until the plainly demonstrated, legitimate issues of fault and damages are resolved. See LeFevre, 590 So.2d at 159; Bowers, 460 So.2d at 1290; Quick, 429 So.2d at 1035."
The trial court stated in its order of dismissal that it was dismissing Pontius's breach-of-contract and bad-faith claims under both Rule 12(b)(6) and Rule 12(c), Ala. R. Civ. P. In Reed Elsevier, Inc. v. The-Law.net Corp., 269 F.Supp.2d 942, 947 (S.D.Ohio 2003), the federal district court stated with regard to Rule 12(b)(6) and Rule 12(c), Fed.R.Civ.P.:[3]
"These rules serve similar ends, insofar as they are dispositive motions, but at their cores they have distinct purposes. Rule 12(b)(6) is concerned with the technical sufficiency of the allegations in the complaint; under any reasonable construction of the facts, as pled, is there a recognized legal basis for granting the plaintiff the relief he seeks? In the Rule 12(b)(6) context, the merits of the claim are not supposed to be considered. Rule 12(c), in contrast, is concerned with the merits: accepting the truth of the allegations and assuming arguendo that the plaintiff has stated a technically valid claim, is the defendant nevertheless entitled to a judgment on the merits? See, generally, 5A Charles Alan Wright & Arthur R. Miller, Federal Practice and Procedure §§ 1367, 1368 & 1369 (2d ed.1990); see also Paskvan v. City of *562 Cleveland Civil Serv. Comm'n, 946 F.2d 1233, 1235 (6th Cir.1991)(`The [Rule 12(c)] motion is granted when no material issue of fact exists and the party making the motion is entitled to judgment as a matter of law.'). As noted by Professors Wright and Miller: `The granting of a Rule 12(b) motion merely means that plaintiff has failed to satisfy one of the procedural prerequisites for asserting his claim for relief. A motion for a judgment on the pleadings, however, theoretically is directed towards a determination of the substantive merits of the controversy....' 5A Wright & Miller, § 1369, at 532-33.
"The difference between the two types of motions stems from when in the course of proceedings they can be raised. Motions brought under Rule 12(b)(6), indeed, under 12(b) generally, must be brought by a defendant `before pleading' (i.e., before filing its answer to the complaint). Motions brought under Rule 12(c) cannot be filed until `[a]fter the pleadings are closed' (i.e., after filing its answer). Still and all, the standard for reviewing Rule 12(c) motions is often identical to that used for reviewing Rule 12(b)(6) motions, given that Rule 12(c) can be invoked in a number of situations where a Rule 12(b) motion could have been, but was not, filed by the defendant. See Rule 12(h)(2) & (3); 5A Wright & Miller § 1368, at 514-17. Thus, often times, after a responsive pleading has been filed, a defendant will move to dismiss for failure to state a claim under Rule 12(c), even though there may be no need to refer to the responsive pleading, such that it would have been proper to move for dismissal under Rule 12(b)(6). In such an instance, it is proper to treat the motion in the manner as one brought pursuant to Rule 12(b)(6). See id., at 515. Moreover, where the pleadings are closed but a defendant mistakenly moves to dismiss under Rule 12(b)(6), instead of Rule 12(c), the Sixth Circuit has held that `where the substance of the motion is plain,' it is proper to treat a motion styled as one under Rule 12(b)(6) as if it were brought under Rule 12(c). See Wagner v. Higgins, 754 F.2d 186, 188 (6th Cir.1985)."
(Footnote omitted.)
This Court has stated: "The [Rule] 12(b)(6) motion should not be used to test the sufficiency of a complaint after a responsive pleading has been filed." Sims v. Lewis, 374 So.2d 298, 301 (Ala.1979)(emphasis added). Rule 12(h)(2), Ala. R. Civ. P., preserves the defense of failure to state a claim:
"(2) A defense of failure to state a claim upon which relief can be granted, a defense of failure to join a party indispensable under Rule 19, and an objection of failure to state a legal defense to a claim may be made in any pleading permitted or order under Rule 7(a), or by motion for judgment on the pleadings, or at the trial on the merits."
Thus, a defense of failure to state a claim upon which relief can be granted, although typically raised pursuant to Rule 12(b)(6), can be raised after an answer has been filed by moving for a judgment on the pleadings.
Although the defense of failure to state a claim clearly can be raised after and answer has been filed, State Farm is arguing that Pontius's claims are not ripe for adjudication. Ripeness implicates subject-matter jurisdiction. Conseco Fin. Corp. of Alabama v. Slay, 839 So.2d 617 (Ala.2002); Baldwin County v. Palmtree Penthouses, Ltd., 831 So.2d 603 (Ala.2002). This Court will look at the substance of a motion, rather than its title, to determine how that motion is to be considered under *563 the Alabama Rules of Civil Procedure. Ex parte Alfa Mut. Gen. Ins. Co., 684 So.2d 1281 (Ala.1996). A Rule 12(b)(1), Ala.R.Civ.P., motion challenges the court's subject-matter jurisdiction and should be filed before a responsive pleading is filed. However, under Rule 12(h)(3), a motion to dismiss for lack of subject-matter jurisdiction may be filed at any time. Thus, we will treat State Farm's motion for partial dismissal or for a partial judgment under Rule 12(b)(6) or Rule 12(c) as a motion to dismiss for lack of subject-matter jurisdiction filed under Rule 12(h)(3).
In Newman v. Savas, 878 So.2d 1147 (Ala.2003), this Court set out the standard of review of a ruling on a motion to dismiss for lack of subject-matter jurisdiction:
"A ruling on a motion to dismiss is reviewed without a presumption of correctness. Nance v. Matthews, 622 So.2d 297, 299 (Ala.1993). This Court must accept the allegations of the complaint as true. Creola Land Dev., Inc. v. Bentbrooke Housing, L.L.C., 828 So.2d 285, 288 (Ala.2002). Furthermore, in reviewing a ruling on a motion to dismiss we will not consider whether the pleader will ultimately prevail but whether the pleader may possibly prevail. Nance, 622 So.2d at 299."
878 So.2d at 1148-49.
State Farm contends that the face of the Pontiuses' amended complaint clearly demonstrates that a legitimate dispute exists concerning liability and damages arising out of the underlying accident. State Farm argues that Alabama law does not recognize a cause of action for breach of contract or bad-faith failure to pay an insurance claim in the context of UIM coverage until liability and damages have been fixed. In other words, State Farm argues that there must be a conclusive determination of liability and damages before State Farm, as the plaintiff's liability carrier, can be liable for breach of contract or bad faith, and that there can be no breach-of-contract or bad-faith claim against the UIM carrier arising out of the investigation, evaluation, or processing of the UIM claim before there is a judgment or settlement of the underlying suit.
This Court has held that "there can be no breach of an uninsured motorist contract, and therefore no bad faith, until the insured proves that he is legally entitled to recover." Quick v. State Farm Mut. Auto. Ins. Co., 429 So.2d 1033, 1035 (Ala.1983). In LeFevre v. Westberry, 590 So.2d 154, 159 (Ala.1991), we stated:
"Uninsured motorist coverage in Alabama is a hybrid in that it blends the features of both first-party and third-party coverage. The first-party aspect is evident in that the insured makes a claim under his own contract. At the same time, however, third-party liability principles also are operating in that the coverage requires the insured to be `legally entitled' to collect  that is, the insured must be able to establish fault on the part of the uninsured motorist and must be able to prove the extent of the damages to which he or she would be entitled. The question arises: when is a carrier of uninsured motorist coverage under a duty to pay its insured's damages?
"There is no universally definitive answer to this question or to the question when an action alleging bad faith may be maintained for the improper handling of an uninsured or underinsured motorist claim; the answer is, of course, dependent upon the facts of each case. Clearly, there is a covenant of good faith and fair dealing between the insurer and the insured, as with direct insurance, but the insurer and the insured occupy adverse positions until the uninsured motorist's *564 liability is fixed; therefore, there can be no action based on the tort of bad faith based on conduct arising prior to that time, only for subsequent bad faith conduct."
The LeFevre Court set out the following general rules for a claim for uninsured/underinsured-motorist benefits:
"1. When a claim is filed by its insured, the uninsured motorist carrier has an obligation to diligently investigate the facts, fairly evaluate the claim, and act promptly and reasonably.
"2. The uninsured motorist carrier should conclude its investigation within a reasonable time and should notify its insured of the action it proposes with regard to the claim for uninsured motorist benefits.
"3. Mere delay does not constitute vexatious or unreasonable delay in the investigation of a claim if there is a bona fide dispute on the issue of liability.
"4. Likewise, mere delay in payment does not rise to the level of bad faith if there is a bona fide dispute on the issue of damages.
"5. If the uninsured motorist carrier refuses to settle with its insured, its refusal to settle must be reasonable."
590 So.2d at 161 (footnotes omitted).
In the present case, Pontius did not have to obtain a judgment against the Martins before she joined State Farm as a defendant in her claim for UIM benefits. See State Farm Fire & Cas. Co. v. Lambert, 291 Ala. 645, 285 So.2d 917 (1973). As to her bad-faith claim arising out of her UIM coverage with State Farm, Pontius had to demonstrate that she was "legally entitled to recover" damages for bad-faith failure to pay under the policy, and she "`must be able to establish fault on the part of the uninsured motorist, which gives rise to damages and must be able to prove the extent of those damages.'" LeFevre, 590 So.2d at 157, quoting Quick, 429 So.2d at 1035. "[W]here a legitimate dispute exists as to liability, whether under primary coverage or uninsured motorist coverage, a tort action for bad faith refusal to pay a contractual claim will not lie." Bowers v. State Farm Mut. Auto. Ins. Co., 460 So.2d 1288, 1290 (Ala.1984). Breach of an insurance contract is an element of a bad-faith-failure-to-pay claim. Ex parte Alfa Mut. Ins. Co., 799 So.2d 957 (Ala.2001). "There can be no breach of an insurance contract providing uninsured-motorist coverage until the insureds prove that they are legally entitled to recover." Ex parte State Farm Mut. Auto. Ins. Co., 893 So.2d 1111, 1115 (Ala.2004).
We agree with State Farm that Pontius's breach-of-contract and bad-faith claims were not ripe for adjudication. Without a determination of whether liability exists on the part of the underinsured motorist and the extent of the plaintiff's damages, a claim of bad-faith failure to pay or breach of contract is premature. The trial court properly dismissed the claims because the claims were not ripe for adjudication. However, as discussed earlier, State Farm's motion challenges the subject-matter jurisdiction of the court. A dismissal for lack of subject-matter jurisdiction does not operate as an adjudication on the merits. See Ex parte Capstone Dev. Corp., 779 So.2d 1216 (Ala.2000)(a dismissal for lack of subject-matter jurisdiction is treated as a dismissal without prejudice to the plaintiff's right to reinstitute the action). Therefore, the trial court should have dismissed Pontius's breach-of-contract and bad-faith claims without prejudice. See also Stringfellow v. State Farm Life Ins. Co., 743 So.2d 439 (Ala.1999)(insured's unripe fraud action should properly have been dismissed without *565 prejudice in order to allow the insured to bring the action when it presented a justiciable controversy). Therefore, the judgment of dismissal is modified to provide that the dismissal of Pontius's breach-of-contract and bad-faith claims is without prejudice to Pontius's right to refile those claims.
We recognize that Pontius has now resolved her underlying lawsuit against the Martins. Based on LeFevre, there can be no bad-faith action based on conduct arising before the uninsured motorist's liability is established and damages are fixed; therefore, "there can be no action based on the tort of bad faith based on conduct arising prior to that time, only for subsequent bad faith conduct." 590 So.2d at 159. Accordingly, any claims alleging bad-faith failure to pay an insurance claim or breach of contract based on State Farm's failure to pay UIM benefits must be based on conduct arising after the Martins liability was established and damages fixed.
The judgment of dismissal is modified to provide that the dismissal of Pontius's bad-faith-failure-to-pay and breach-of-contract claims is without prejudice to Pontius's right to refile those claims, and as so modified, the judgment of dismissal is affirmed.
AFFIRMED AS MODIFIED.
NABERS, C.J., and SEE, HARWOOD, and STUART, JJ., concur.
NOTES
[1]  This case was originally assigned to another Justice; it was reassigned to Justice Bolin on January 17, 2005.
[2]  Anna was appointed personal representative of Andrew's estate and in that capacity was substituted as a plaintiff.
[3]  Cases interpreting the Federal Rules of Civil Procedure can be persuasive authority in construing the Alabama Rules of Civil Procedure because of the similarities between the Alabama rules and the federal rules. Bracy v. Sippial Elec. Co., 379 So.2d 582 (Ala.1980).
