
766 P.2d 884 (1988)
Jay Lee GATES, and Mark J. Andrus, Petitioners,
v.
MISSOULA COUNTY COMMISSIONERS, Daniel Magone, Sheriff, Dr. Long, Chief of Medical Services, Respondents.
No. 88-401.
Supreme Court of Montana.
Submitted on Briefs December 2, 1988.
Decided December 29, 1988.
Jay Lee Gates, Deer Lodge, pro se. Mark J Andrus, Missoula, pro se.
Mike Greely, Atty. Gen., Helena, Robert Deschamps, III, Co. Atty., Michael W. Sehestedt, Deputy, Missoula, for respondents.
WEBER, Justice.
Jay Lee Gates and Mark Andrus petition this Court for relief under the habeas corpus and declaratory judgment statutes. They allege a violation of their constitutional rights due to several conditions of confinement at the Missoula County Jail. Petitioners also allege a tort cause of action against Missoula County officials for the violation of their constitutional rights. We dismiss the petitioners' claim for relief.
The issues involved in this matter are:
1. Is habeas corpus an appropriate remedy?
2. Does this Court have jurisdiction to consider Petitioners' request for relief as a declaratory judgment or a tort cause of action?
Both petitioners were incarcerated in the Missoula County Jail in Missoula, Montana, at the filing of this petition. Since that date, Mr. Gates has been transferred to Montana State Prison in Deer Lodge and Mr. Andrus' six month term in the Missoula County Jail beginning in April of 1988 has presumably been served. During the periods of their incarceration in Missoula, the petitioners contend that they were denied adequate food, shelter, clothing, medical care, exercise, individual security, and a law library, all of which violated their constitutional rights under the 8th Amendment's protection against cruel and unusual punishment, the similar prohibition in Article II, Section 22 of the Montana Constitution, and also the 14th Amendment of the U.S. Constitution.

I
Is habeas corpus an appropriate remedy?
The habeas corpus statute § 46-22-101(1), MCA, provides that:
... every person imprisoned or otherwise restrained of his liberty within this state may prosecute a writ of habeas corpus to inquire into the cause of such imprisonment and restraint and, if illegal, to be delivered therefrom. (Emphasis added.)
This statute allows a prisoner to challenge the legal sufficiency of the cause for incarceration. The petitioners do not allege that the cause of their incarceration *885 is unlawful. We conclude that habeas corpus is not an appropriate remedy.

II
Does this Court have jurisdiction to consider Petitioner's request for relief as a declaratory judgment or a tort cause of action?
Petitioners seek declaratory and injunctive relief against Missoula County officials whom they contend have control over the care and condition of the facility in question. The Montana Supreme Court's power to hear any matter by exercising original jurisdiction is subject to Rule 17(a), M.R.App.P.:
The supreme court is an appellate court but it is empowered by the constitution of Montana to hear and determine such original and remedial writs as may be necessary or proper to the complete exercise of its jurisdiction. The institution of such original proceedings in the supreme court is sometimes justified by circumstances of an emergency nature, as when a cause of action or a right has arisen under conditions making due consideration in the trial courts and due appeal to this court an inadequate remedy, or when supervision of a trial court other than by appeal is deemed necessary or proper.
In determining whether to assume original jurisdiction in light of that rule, this Court has considered several factors as set forth in State ex rel Thompson v. School District (1970), 156 Mont. 79, 80, 474 P.2d 700, 701:
"... various fact questions appear ... original jurisdiction by this Court will not achieve a thorough examination into the multiple problems presented, and, further, a class action could be instituted in any appropriate district court wherein exists facilities for taking testimony and making findings of fact and conclusions of law which would be determinative of the fact questions now existing .. ."
Mr. Gates and Mr. Andrus present a number of factual questions which they ask this Court to resolve. Those disputed factual issues should be directed to an appropriate district court, since it is not the role of this Court to function as primary factfinder. The petitioners have not demonstrated any emergency which would justify a departure from the usual proceedings in district court to decide the merits of the issues raised. Furthermore, the County points out that at the time this petition was filed, there was a class action pending in which the petitioners were involved, counsel was appointed, and the same issues were raised in that suit as appear in this matter.
We conclude that there is no basis upon which this Court should accept jurisdiction. Petitioners' request for relief is denied and dismissed, without prejudice.
TURNAGE, C.J., and SHEEHY, McDONOUGH and GULBRANDSON, JJ., concur.
