changing the conditional had one minor bug, fixed the way I was calculating the length of the array