Correct the function converting categories