Fixed x y coordinate swap problem