Fix coordinate transformation bug