check for a valid array before looping on indexes