                                     )
 
   _moveTo: (target) ->
+    if @callStack >= MAX_CALL_STACK
+      @_stopAnimation()
+      return
+
+    @callStack++
     if PointHelper.compare(@currentPosition, target)
       # I am on spot
       return

    @_refreshPosition()
    @currentStreetDirection = StreetDirection.CROSS
    @currentAnimation = null

  _refreshPosition: () ->
    @source.attr('x', @currentPosition.getX() - @carWidth / 2)

class Car
  MAX_CALL_STACK = 30

  class StreetDirection
    @CROSS = 0
    @HORIZONTAL = 1
