Only loop through array indices and error checking