anchor.diff:      case (Alarm =/= unknown_alarm) andalso (Alarm#alarm.state =:= active) andalso
                IsLeader andalso (Epoch =:= AlarmEpoch) of
           true ->
  -            LeaderPid = self(),
  -            % spawn alarm handler and 
  -            _ = spawn(fun() ->
  -                              case check_alarm(Alarm#alarm.handler, Alarm) of
  -                                  unknown_alarm_handler ->
  -                                      ok;
  -                                  breach_lower ->
  -                                      continue_alarm(Name, erlang:max(Alarm#alarm.period_secs, Alarm#alarm.cooldown_secs), LeaderPid, Epoch),
  -                                      ?CLOUD:remove_vms(Alarm#alarm.scale_down_by);
  -                                  breach_upper ->
  -                                      continue_alarm(Name, erlang:max(Alarm#alarm.period_secs, Alarm#alarm.cooldown_secs), LeaderPid, Epoch),
  -                                      ?CLOUD:add_vms(Alarm#alarm.scale_up_by);
  -                                  ok ->
  -                                      continue_alarm(Name, Alarm#alarm.period_secs, LeaderPid, Epoch)
  -                              end
  -                      end),
  +        LeaderPid = self(),
  +            % call alarm handler and reacht to breach_state 
  +            case check_alarm(Alarm#alarm.handler, Alarm) of
  +                unknown_alarm_handler ->
  +                    ok;
  +                breach_lower ->
  +                    continue_alarm(
  +                        Name,
  +                        erlang:max(Alarm#alarm.period_secs, Alarm#alarm.cooldown_secs),
  +                        LeaderPid, Epoch),
  +                    ?CLOUD:remove_vms(Alarm#alarm.scale_down_by);
  +                breach_upper ->
  +                    continue_alarm(
  +                        Name,
  +                        erlang:max(Alarm#alarm.period_secs, Alarm#alarm.cooldown_secs),
  +                        LeaderPid, Epoch),
  +                    ?CLOUD:add_vms(Alarm#alarm.scale_up_by);
  +                ok ->
  +                    continue_alarm(Name, Alarm#alarm.period_secs, LeaderPid, Epoch)
  +            end
               ok;
           false ->
               ok
  
positive.code: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  -spec continue_alarm(atom(), pos_integer(), pid(), non_neg_integer()) -> ok.
  continue_alarm(Name, Secs, Pid, Epoch) ->
      io:format("Alarm '~p' for ~p delayed by ~p seconds (Epoch ~p).~n", [Name, Pid, Secs, Epoch]),
      msg_delay:send_local(Secs, Pid, {check_alarm, Name, Epoch}).
  
  update_alarm(Alarms, Name, {Field, NewValue}) ->
  
negative.code: % types
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  -type(alarm_handler() ::
        load_avg |
        latency_avg |
        random_churn).
  
  -record(alarm,
      {
          name             = ?required(alarm, name) :: atom(),
          handler          = ?required(alarm, handler) :: alarm_handler(),
          period_secs      = ?required(alarm, period_in_s) :: pos_integer(),
          cooldown_secs    = 0 :: non_neg_integer(),
          lower_limit      = ?MINUS_INFINITY :: number(),
          upper_limit      = ?PLUS_INFINITY :: number(),
          scale_down_by    = 1 :: non_neg_integer(),
          scale_up_by      = 1 :: non_neg_integer(),
          state             = active :: active | inactive,
          opt_fields       = [] :: [{atom(), any()}]
      }).
  
  -type(state() ::
      {IsLeader::boolean(), Alarms::dict()} |
      unknown_event).
  
  -type(breach_state() ::
      breach_lower |
      breach_upper |
      ok).
  
  -type(message() ::
      {get_state_response, MyRange::intervals:interval()} |
      {check_alarm, Name::atom()} |
      {toggle_alarm, Name::atom()} |
      {deactivate_alarms, Name::atom()}).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % startup
  