max refactoring