fixed problem in writing coords