Fixed collection iteration by using .to_a