improved clean func.