fix bug
reduce tmp array size