@kizu, I'd move `variants[values[i]]` and `values[i]` to variables with meaningful names.
Now it's hard to say for what those values stand.