Wrong array assignment to variable