finished coor_x function