fixmed a math bug in coordinate conversion