Make sure packages is an array before looping over it.