anchor.diff:              add_chart ->
                   gui_utils:remove("error_message"),
                   gui_utils:flush(),
  -                case validate(PageState) of
  +                case validate_page_state(PageState) of
                       ok ->
  -                        reset_dropdowns(Nodes),
  -                        case create_chart(Counter, Node, TimeRange, ChartType) of
  -                            {ok, Chart} ->
  -                                erlang:send_after(1000 * Chart#chart.update_period, self(), {update_chart, Counter}),
  -                                ?MODULE:comet_loop(Counter + 1, PageState#page_state{node = undefined, time_range = undefined, chart_type = undefined, charts = dict:store(Counter, Chart, Charts)});
  -                            _ ->
  -                                error_message(<<"There has been an error in chart creation. Please try again.">>),
  -                                ?MODULE:comet_loop(Counter, PageState#page_state{node = undefined, time_range = undefined, chart_type = undefined})
  +                        case validate_chart(Node, TimeRange, ChartType, Charts) of
  +                            ok ->
  +                                case create_chart(Counter, Node, TimeRange, ChartType) of
  +                                    {ok, Chart} ->
  +                                        reset_dropdowns(Nodes),
  +                                        erlang:send_after(1000 * Chart#chart.update_period, self(), {update_chart, Counter}),
  +                                        ?MODULE:comet_loop(Counter + 1, PageState#page_state{node = undefined, time_range = undefined, chart_type = undefined, charts = [{Counter, Chart} | Charts]});
  +                                    _ ->
  +                                        error_message(<<"There has been an error in chart creation. Please try again.">>)
  +                                end;
  +                            _ -> error_message(<<"Chart already added.">>)
                           end;
  -                    _ ->
  -                        ?MODULE:comet_loop(Counter, PageState)
  -                end;
  +                    _ -> ok
  +                end,
  +                ?MODULE:comet_loop(Counter, PageState);
   
               {update_chart, Id} ->
                   try
  -                    Chart = dict:fetch(Id, Charts),
  -                    ok = update_chart(Chart),
  -                    erlang:send_after(1000 * Chart#chart.update_period, self(), {update_chart, Id})
  +                    case proplists:get_value(Id, Charts) of
  +                        undefined ->
  +                            ?error("Can not update chart ~p: chart does not exist.", [Id]);
  +                        Chart ->
  +                            ok = update_chart(Chart),
  +                            erlang:send_after(1000 * Chart#chart.update_period, self(), {update_chart, Id})
  +                    end
                   catch
                       _:Error -> ?error("Can not update chart ~p: ~p", [Id, Error])
                   end,
  
positive.code:     gui_utils:flush().
  
  
  %% validate/1
  %% ====================================================================
  %% @doc Checks whether user has selected all requiered options to plot chart
  -spec validate(PageState :: #page_state{}) -> ok | error.
  %% ====================================================================
  validate(#page_state{node = undefined}) ->
      error_message(<<"Please select host.">>),
      error;
  validate(#page_state{time_range = undefined}) ->
      error_message(<<"Please select time range.">>),
      error;
  validate(#page_state{chart_type = undefined}) ->
      error_message(<<"Please select chart type.">>),
      error;
  validate(_) ->
      ok.
  
  
  %% host_dropdown_body/0
  
negative.code:             {delete_chart, Id} ->
                  wf:wire("deleteChart(\"" ++ integer_to_list(Id) ++ "\");"),
                  gui_utils:flush(),
                  ?MODULE:comet_loop(Counter, PageState#page_state{charts = proplists:delete(Id, Charts)})
  
          end
      catch Type:Msg ->
  