   center1 = entityCoordinates(entity1, 0.5, 0.5)
   center2 = entityCoordinates(entity2, 0.5, 0.5)
 
-  if vertical(center1, center2)
+  if closer_to_vertical_than_horizontal(entity1, entity2)
+
     if center1.y < center2.y
       p1.side = "bottom"
       p2.side = "top"


  $('#relationship' + relationship).attr('d', svg_path)

relationshipEndpoints = (entity1, entity2) ->
  p1 = {}
  p2 = {}

    p1.y = entityCoordinate(entity1, p1.side)
    p2.y = entityCoordinate(entity2, p2.side)

    if fully_vertical(entity1, entity2)
      p1.x = Math.round((center1.x + center2.x) / 2)
      p2.x = p1.x
    else
      if center1.x < center2.x
        p1.x = entityCoordinate(entity1, "right") - MARGIN
        p2.x = entityCoordinate(entity2, "left" ) + MARGIN
      else
        p1.x = entityCoordinate(entity1, "left" ) + MARGIN
        p2.x = entityCoordinate(entity2, "right") - MARGIN

  else # closer to horizontal than vertical

    if center1.x < center2.x
      p1.side = "right"
      p2.side = "left"
