Refactoring scrub function.