fix error when layer variable is an array