Start of function to correct data in X