Move to_polar() to "functions" and simplify it