refactoring min