cleaning and finalizing