Strange behaviour setting pinMode by array

try incorporating your changes