Update conversion to handle edge cases better.