Added changes as suggested by Jo Liss. Altered the array itteration to a safer and more traditional approach.