anchor.diff:          { OldListUpdated, [NewData | NewList] }
       end, {OldBusLocationList, []}, BusLocationList).
   
  -io_format_history(History, MonthDay) ->
  -    io_format_history(History, [], MonthDay).
  -
  -io_format_history([], Result, _MonthDay) ->
  +check_route(#state{route_updated_at=undefined, last_error=undefined}=State) ->
  +    check_route1(State);
  +
  +check_route(#state{route_updated_at=RouteUpdatedAt, last_error=undefined}=State) ->
  +    case timer:now_diff(os:timestamp(), RouteUpdatedAt) >= ?INTERVAL_ROUTE of
  +        true ->
  +            check_route1(State);
  +        _ ->
  +            State
  +    end;
  +
  +check_route(State) ->
  +    check_route1(State).
  +
  +check_route1(#state{id=BusId, route_raw=RouteRaw} = State) ->
  +    lager:debug("check route ~p", [BusId]),
  +
  +    {ok, {{_NewVersion, 200, _NewReasonPhrase}, _NewHeaders, NewBody}} =
  +        httpc:request(get, {get_route_url(BusId), [{"User-Agent", "Mozilla/5.0"}]}, [], []),
  +    BBody = list_to_binary(NewBody),
  +
  +    case BBody of
  +        RouteRaw -> State;
  +        _ ->
  +            Json = jsx:decode(BBody),
  +            Result = proplists:get_value(<<"result">>, Json),
  +            BusFirstTimeRaw = proplists:get_value(<<"busFirstTime">>, Result),
  +            BusFirstTime = case BusFirstTimeRaw of
  +                BusFirstTimeBinary when is_binary(BusFirstTimeBinary) ->
  +                    BusFirstTimeList = binary_to_list(BusFirstTimeBinary),
  +                    case BusFirstTimeList of
  +                        [H1, H2, $:, M1, M2] ->
  +                            { [H1, H2], [M1, M2] };
  +                        _ ->
  +                            undefined
  +                    end;
  +                _ -> undefined
  +            end,
  +            Stations = proplists:get_value(<<"station">>, Result),
  +            StationLen = length(Stations),
  +            StationArray0 = array:new([{size,StationLen}, {fixed, false}, {default, <<"">>}]),
  +            {StationArray, _} = lists:foldl(
  +                                fun(Station, {Array, Index}) ->
  +                                        Name = proplists:get_value(<<"stationName">>, Station),
  +                                        {array:set(Index, Name, Array), Index+1}
  +                                end, {StationArray0, 0}, Stations),
  +            lager:info("route changed ~p", [BusId]),
  +            State#state{
  +              station_array=StationArray,
  +              route_raw=BBody,
  +              bus_first_time=BusFirstTime,
  +              route_updated_at=os:timestamp()
  +             }
  +    end.
  +
  +io_format_history(History, MonthDay, StationArray) ->
  +    io_format_history(History, [], MonthDay, StationArray).
  +
  +io_format_history([], Result, _MonthDay, _StationArray) ->
       Result;
  -io_format_history([{Location, UpdateDate}|Tail], Result, MonthDay) ->
  +io_format_history([{Location, UpdateDate}|Tail], Result, MonthDay, StationArray) ->
  +    StationName = array:get(Location, StationArray),
       io_format_history(Tail,
                         [[<<"{\"">>, integer_to_list(Location), <<"\":">>,
  -                        <<"\"">>, format_date(UpdateDate, MonthDay), <<"\"},">> ] | Result], MonthDay).
  +                        <<"{\"t\":\"">>, format_date(UpdateDate, MonthDay), <<"\",">>,
  +                        <<"\"n\":\"">>, StationName, <<"\"}},">> ] | Result],
  +                      MonthDay, StationArray).
   
   format_date(UpdateDate, {MonthRef, DayRef}) ->
       {Year, Month, Day, Hour, Minute, Second} = split_update_date(UpdateDate),
  
positive.code:             case lists:keytake(PlateNo, 1, OldList) of
                  {value, {_, [{LastStationSeq, _LastUpdateDate}|_]=History}, OldListUpdated1} ->
                      if
                          StationSeq > LastStationSeq ->
                              % Update bus
                              { OldListUpdated1, {PlateNo, [{StationSeq, UpdateDate} | History]} };
                          StationSeq < LastStationSeq ->
                              % New bus
                              { [ {PlateNo, History} | OldListUpdated1], {PlateNo, [{StationSeq, UpdateDate}]} };
                          true ->
                              % No update
                              { OldListUpdated1, {PlateNo, History} }
                      end;
                  false -> 
                      % New bus
  
negative.code:                     mkdir_p(Path, []),
                      FileName = string:join(Path, "/") ++ "/" ++ Day ++ ".txt",
                      {ok, IoDevice} = file:open(FileName, [append, {encoding, utf8}]),
                      io:format(IoDevice, "{ \"~ts\" : [~ts]},~n",
                                [PlateNo,
                                 io_format_history(
                                   History, {Month, Day}, NewState#state.station_array)]),
                      ok = file:close(IoDevice)
                  end, Obsoletes)
      end,
  
      NewState#state{ bus_loc_list=NewBusLocationList, loc_updated_at=os:timestamp()}.
  
  
  update_bus_loc_list(OldBusLocationList, BusLocationList) ->
      lists:foldl(
      fun(BusLocation, {OldList, NewList}) ->
          StationSeq = proplists:get_value(<<"stationSeq">>, BusLocation),
  