error checking in reading data