refactoring maxcubehandler