
559 S.W.2d 736 (1977)
Donald Ray POLSGROVE, Appellant,
v.
KENTUCKY BUREAU OF CORRECTIONS, Appellee.
Supreme Court of Kentucky.
December 9, 1977.
David E. Murrell, Deputy Public Defender, Frankfort, for appellant.
Robert F. Stephens, Atty. Gen., George Geoghegan, III, Asst. Atty. Gen., Frankfort, for appellee.
JONES, Justice.
Donald Ray Polsgrove filed a petition for a declaratory judgment in Franklin Circuit Court. He requested that the Bureau of Corrections be directed to award him full "good-time" credit for the time spent in the county jail prior to his conviction and sentence. The trial court granted the Bureau's motion to dismiss Polsgrove's petition. The Court of Appeals affirmed the order of the trial court in an opinion published at 549 S.W.2d 834 (1977). The Court of Appeals based its decision upon the grounds that: (1) Polsgrove sought the remedy by means of a declaratory judgment and, (2) habeas corpus is the exclusive remedy for Polsgrove to obtain the relief sought. This court granted discretionary review.
The relevant facts to the actual controversy reveal that Polsgrove was arrested on November 19, 1974 and placed in the Jefferson County Jail. On September 26, 1975, the Jefferson Circuit Court sentenced Polsgrove to a five-year prison term. Polsgrove was transferred to the Kentucky State Reformatory to begin serving his sentence on October 2, 1975. Because Polsgrove was unable to post bond he was lodged in the Jefferson County Jail from November 19, 1974, until October 2, 1975, a total of 317 days. The trial court credited Polsgrove's maximum sentence with the 317 days he had been in custody prior to the commencement of his sentence. However, the Bureau of Corrections credited Polsgrove with 230 days "adjusted jail credit time." Polsgrove's argument hinges upon the interpretation of KRS 197.045(1) and KRS 532.120(3).
KRS 197.045(1) provides in part:
"Any person convicted and sentenced to a state penal institution may receive a *737 credit on his sentence of not exceeding ten (10) days for each month served, except as outlined in subsection (3) of this section, to be determined by the bureau from the conduct of the prisoner. . ."
KRS 532.120(3) provides:
"Time spent in custody prior to the commencement of a sentence as a result of the charge that culminated in the sentence shall be credited by the court imposing sentence toward service of the maximum term of imprisonment. If the sentence is to an indeterminate term of imprisonment, the time spent in custody prior to the commencement of such service shall be considered for all purposes as time served in prison."
The commentary to KRS 532.120(3):
"Subsection (3) requires that an offender be given credit for all time spent in custody prior to the commencement of his term of imprisonment. The provision imposes a duty on the trial judge to see that this credit is properly given. This is the surest way to guarantee against oversight of the credit. The second part of the subsection intends to extend the applicability of the credit to such matters as `good time credit' on an indeterminate sentence and parole eligibility." (Emphasis added).
Polsgrove is correct in the interpretation of the foregoing sections which require that he receive "good-time credit" for the 317 days spent in custody prior to the commencement of his sentence. This court is of the opinion that this result is mandated by the clear language of KRS 532.120(3), which provides that pre-institutional custody time is to be counted for all purposes as "time served in prison." This court finds no difficulty in construing KRS 532.120(3) compatible with KRS 197.045(1).
Polsgrove is not seeking immediate release, but a reduction of his sentence. In this jurisdiction it has been held as far back as "the memory of man runneth not to the contrary" that in criminal cases a writ of habeas corpus has been esteemed the best and only sufficient defense of personal freedom, having for its object the speedy release by judicial decree of persons who are illegally restrained of their liberty. Under our present statute dealing with habeas corpus KRS 419.020 provides:
"The writ of habeas corpus shall be issued upon petition on behalf of anyone showing by affidavit probable cause that he is being detained without lawful authority or is being imprisoned when by law he is entitled to bail. The writ may be issued by any circuit judge on any day or any time and his power to issue such writs shall be coexistive with the Commonwealth."
Therefore, the decision of the Court of Appeals was in error by its holding that the dismissal of Polsgrove's petition was proper because it was brought in an "improper fashion," and that habeas corpus relief was exclusive.
This court is of the view that the declaratory relief sought by Polsgrove in the Franklin Circuit Court was appropriate.
"In any action in a court of record of this commonwealth having general jurisdiction wherein it is made to appear that an actual controversy exists, the plaintiff may ask for a declaration of rights, either alone or with other relief; and the court may make a binding declaration of rights, whether or not consequential relief is or could be asked." KRS 418.040.
This court notes that the opinion of the Court of Appeals for good measure attempts to set out the proper guidelines in the event that Polsgrove filed a petition "in proper fashion" (habeas corpus).
Under this court's holding it is unnecessary for Polsgrove to seek such a writ. He has pursued the proper course. The Bureau of Corrections is charged with the duty of determining the conduct of a prisoner prior to the commencement of his sentence. KRS 532.050.
The ruling of the Court of Appeals is reversed with directions that this cause be remanded to the Franklin Circuit Court *738 with directions to enter a declaratory judgment consistent herewith.
The judgment is reversed.
All concur.
