s: separate the coordinate inversion code