Change max+1 to max, so it is idempotent