Improving cleanup using trap