cleaning up diag max and min