Updated clean function