Fixed fatal bug for extractData function that could occur under certain circumstances