fix bug in the dispose methods