cleanup implementation