debugging cleaning function