This check should be performed in a more efficient manner, that is, by iterating over the data. Further, it looks like all this error checking occurs after the user already has received some data, meaning they might accidentally perform computations on bad data, seems like a big foot gun?