adding cleanup and init function