fixed clean function