
633 P.2d 311 (1981)
David SCHWING, Appellant,
v.
STATE of Alaska, Appellee.
No. 5695.
Court of Appeals of Alaska.
September 10, 1981.
*312 Nancy Shaw, Asst. Public Defender and Dana Fabe, Acting Public Defender, Anchorage, for appellant.
David Mannheimer, Asst. Atty. Gen., Anchorage, and Wilson L. Condon, Atty. Gen., Juneau, for appellee.
Before BRYNER, C.J., and COATS and SINGLETON, JJ.

OPINION
COATS, Judge.
David Schwing was originally indicted for five counts of sale of cocaine to the same police informant on different dates in April, May, and June of 1980. One of the counts was dismissed early in the case and was not the subject of any plea negotiations. Ultimately Schwing pled guilty to counts I and II in exchange for a dismissal of counts III and IV. Schwing was sentenced by Superior Court Judge Mark Rowland, who suspended imposition of sentence and placed Schwing on probation for a period of three years. Judge Rowland imposed the following special conditions of probation: 1) The defendant was required to serve six months in a correctional facility; 2) the defendant was required to make restitution in the amount of $2,800; and 3) upon release the defendant was to enter and successfully complete a drug rehabilitation program such as Akeela House.
Schwing raises two issues in this appeal. First, he contends that he was not given credit for time which he spent in Akeela House, a residential treatment facility, to which he was released on bail prior to sentencing. Second, he claims the trial court erred in requiring him to make restitution of the state money which he received from the five sales of cocaine to the state informant. Schwing claims that since he entered pleas to only two of the five counts of sale of cocaine, he can only be required under the restitution statute, AS 12.55.100(a)(2), to make restitution to the state for the money which he received in those transactions for which he was convicted. We find we must remand this case to the trial court for further proceedings.

CREDIT FOR TIME SERVED
Schwing was incarcerated after he was charged with the cocaine sales. He was then released on bond pending trial to Akeela House, an in-patient drug rehabilitation program. At the time of his sentencing Schwing had accrued 106 days in Akeela House. At the sentencing hearing Schwing's attorney argued that Schwing should be allowed to continue to stay at Akeela House and that no additional incarceration was necessary. After careful reflection, Judge Rowland concluded that the sentencing goals of reaffirmation of societal norms and deterrence of others required him to sentence Schwing to a period of six *313 months incarceration in a correctional facility as a condition of his probation on the suspended imposition of sentence. After this sentence was imposed, Schwing filed a motion to correct his sentence, arguing that Lock v. State, 609 P.2d 539 (Alaska 1980), required him to be given credit toward his sentence of imprisonment for time served in Akeela House. The state did not oppose this motion in the trial court. Judge Rowland denied the motion, stating that in imposing the condition of probation that the defendant serve six months in a correctional facility, he took into account the time which the defendant spent at Akeela House.
In Lock, the supreme court decided that when the trial court revoked a defendant's probation, it had to give credit for the time which the defendant previously served in a residential treatment facility as a condition of his probation. The court based its decision on former AS 11.05.040(a), which read in part:
A person who is sentenced shall receive credit toward service of his sentence for time spent in custody pending trial or sentencing, or appeal, if that detention was in connection with the offense for which sentence was imposed.[1]
The court held that time spent in a residential treatment facility was "time spent in custody." Lock v. State, 609 P.2d at 542.
The state argues on appeal that the Lock rationale does not apply to Schwing's case because it is clear from the sentencing proceeding that the trial judge was aware that Lock had spent 106 days in Akeela House and that he intended for Schwing to serve six months in a correctional facility in addition to the time which Schwing spent in Akeela House. We have reviewed the sentencing proceeding and agree with the state on this point. We further find that Judge Rowland's intention was adequately communicated to the defendant. We therefore find that Judge Rowland did not fail to give Schwing credit for the time which he served in Akeela House and that he did not err in denying Schwing's motion to correct his sentence.[2]

RESTITUTION
The trial court also ordered Schwing to pay restitution in the amount of $2,800 to reimburse the state of Alaska for all of the money which he received from the police informant to whom he sold cocaine. Apparently the $2,800 represents the money which Schwing received for all five cocaine sales; both Schwing and the state agree he received only $800 on the two counts for which he was convicted. Schwing argues that under AS 12.55.100(a)(2) he can only be required to make restitution for the money which he received on the two cocaine sales for which he was ultimately convicted. AS 12.55.100(a)(2) reads as follows:
Conditions of Probation.
(a) While on probation and among the conditions of probation, the defendant may be required ...
(2) to make restitution or reparation to aggrieved parties for actual damages or loss caused by the crime for which conviction was had. [Emphasis supplied.]
The state has confessed error and agrees with Schwing that under the statute he can *314 only be required to pay as restitution the $800 he received for the two counts which resulted in conviction. We have independently reviewed this issue "to insure that the error confessed is supported by the record on appeal and has legal foundation," as we are required to do under Marks v. State, 496 P.2d 66, 67-68 (Alaska 1972). We believe that the state's confession of error is appropriate given the plain language of the statute. We therefore hold that the amount of restitution which Schwing may be required to pay cannot exceed the actual loss caused by the two sales of cocaine for which he was convicted.
The case is REMANDED for further proceedings.
NOTES
[1]  This statute is now codified as AS 12.55.025(c), which reads in part:

A defendant shall receive credit for time spent in custody pending trial, sentencing, or appeal, if the detention was in connection with the offense for which sentence was imposed.
[2]  The state also argues that the rationale of the Lock case does not apply to Schwing because in his case sentence was never imposed. AS 12.55.080(a), the statute under which Schwing was placed on probation, provides that the trial judge may "suspend the imposition of sentence ... and shall place the person on probation." The statute also provides that in the event the person violates his probation "the court may pronounce sentence." AS 12.55.085(c). Thus, the state contends Schwing has never been sentenced under the terms of AS 12.55.085. Since former AS 11.05.040(a) applies to a "person who is sentenced" and AS 12.55.025(c) has similar language, the state contends those statutes and the Lock rationale do not require a defendant automatically to be given credit for time formerly served. We do not decide this issue since it is not necessary in order to dispose of the case before us.
