fix value access while copy to tmp array