fixed out of range error

Olly found a bug in the way i looped through an array