Upgrade min, add clean function