6. The court, after hearing the offender or giving him an opportunity to be heard, may change the conditions of an order made under section 5, or the period during which it shall remain in force, provided that such change does not have the effect of extending such period beyond two years.