max refactor