You could consider making this an object with a constructor and methods clean() and run(f)?