changing patch for #3982 to check if array first.

replaces previous patch.