
566 So.2d 613 (1990)
Milton THOMAS, Appellant,
v.
STATE of Florida, Appellee.
No. 89-1564.
District Court of Appeal of Florida, Fourth District.
September 19, 1990.
*614 Richard L. Jorandby, Public Defender, and Susan D. Cline, Asst. Public Defender, West Palm Beach, for appellant.
Robert A. Butterworth, Atty. Gen., Tallahassee, Patricia G. Lampert and Michael H. Greenfield, Asst. Attys. Gen., West Palm Beach, for appellee.

ON MOTION FOR REHEARING
DELL, Judge.
We deny appellant's motion for rehearing, but withdraw our opinion filed July 25, 1990 and substitute the following:
Milton Thomas appeals from a judgment and sentence for battery on a law enforcement officer. He contends the trial court erred when it denied his motion to withdraw a plea of nolo contendere, ordered him to pay restitution, imposed three special conditions of probation and assessed public defender fees and costs for community service. We affirm in part, reverse in part and remand.
Appellant entered into a written plea agreement which contemplated a four-month sentence with credit for time served, to be followed by probation. The trial court accepted appellant's nolo contendere plea and ordered a presentence investigation report. The Department of Corrections' report recommended three years in prison, with restitution to be ordered if the sentence included probation or work release. Appellant contends the trial court erred when it refused to permit him to withdraw his plea of nolo contendere. He argues that the state did not reaffirm its recommendation pursuant to the plea agreement, citing Curry v. State, 513 So.2d 204 (Fla. 4th DCA 1987).
We find appellant's reliance on Curry misplaced since here the state, albeit reluctantly, reaffirmed its recommendation pursuant to the plea agreement. We are not persuaded by appellant's argument that the state breached the plea agreement by commenting that it would not agree to the court using its recommendation of four months incarceration as a *615 written reason to depart from the guidelines. Appellant makes the alternative argument that if the trial court accepts a plea and then does not impose a sentence in accordance with the plea agreement, it must offer the defendant an opportunity to withdraw his plea and proceed to trial. We disagree. Here, appellant bargained for the prosecutor's recommendation of a four-month sentence. The transcript from the change of plea hearing shows that the prosecutor fulfilled the agreement. See R.C. Stewart v. State, 511 So.2d 375 (Fla. 1st DCA 1987). The trial court conducted the necessary inquiry under the Rules of Criminal Procedure to ensure that the plea was knowingly and intelligently entered and that there was a factual basis for the plea. The court was not bound by the State's recommendation. State v. Adams, 342 So.2d 818 (Fla. 1977). We conclude that appellant was not deprived of the benefit of his bargain and affirm the trial court's denial of appellant's motion to withdraw his plea of nolo contendere.
Appellant next contends, and the state concedes, that the trial court erred when it failed to conduct a proper hearing to determine appellant's ability to pay, before ordering restitution. We reverse the order of restitution and remand this cause to the trial court for further proceedings on this question. See Eloshway v. State, 553 So.2d 1258 (Fla. 4th DCA 1989) and Thomas v. State, 517 So.2d 132 (Fla. 4th DCA 1987).
We find no error in the special conditions of probation imposed by the trial court. The conditions reasonably relate to appellant's past criminality, serve a rehabilitative purpose, and, if the rehabilitation is successful, may prevent future criminality. Therefore, we affirm. See Brown v. State, 406 So.2d 1262 (Fla. 4th DCA 1981); Wiggins v. State, 386 So.2d 46 (Fla. 4th DCA 1980).
Finally, we hold that the trial court erred when it ordered appellant to pay public defender's fees, court costs and other compensation to various funds or to perform community service hours. As amended in 1986, section 27.3455, Florida Statutes, discontinued the community service option. See section 27.3455, Florida Statutes (1989); Houston v. State, 540 So.2d 943 (Fla. 4th DCA 1989); see also Harrison v. State, 557 So.2d 151 (Fla. 4th DCA 1990). We also hold that the trial court erred when it assessed these costs and fees without affording appellant notice and without making a determination of his financial resources and ability to pay. See Jenkins v. State, 444 So.2d 947 (Fla. 1986).
Accordingly, we affirm the trial court's denial of appellant's motion to withdraw his plea of nolo contendere; we affirm the order imposing the special conditions of probation; we reverse the orders imposing restitution, fees and costs or community service hours, and remand for further proceedings consistent with this opinion.
AFFIRMED IN PART; REVERSED IN PART and REMANDED.
DOWNEY and GUNTHER, JJ., concur.
