anchor.diff:      {response(R, login), NewState};
   handle([<<"logout">>], {logged_in} = S) ->
       R = admin:logout(),
  +    close_ws_if_logged_out(R),
       NewState = case R of
   		   {ok} -> {};
   		   _ -> S
  
positive.code: waiting_state(_, S) ->
      S.
  
  handle([<<"login">>, N], {} = S) ->
      lager:debug("LOGIN ~p~n",[N]),
      Name = binary_to_list(N),
  
negative.code:     {ok, Req, S};
  websocket_info({table_closed, _ , _} = Msg, Req, _State) ->
      {reply, {text, jsx:encode(transform(Msg))}, Req, {logged_in}};
  websocket_info({close_ws_conn}, Req, S) ->
      {shutdown, Req, S};
  websocket_info({end_of_game, GameNum, _, _, _, {Score, Points, TotalPoints}}, Req, State) ->
      TricksWon = maps:map(fun( _,{T,_P}) -> T end, Score),
      PointsWon = maps:map(fun( _,{_T,P}) -> P end, Score),
      {reply, {text, jsx:encode(transform({end_of_game, GameNum, TricksWon, PointsWon, Points, TotalPoints}))}, Req, State};
  websocket_info(Msg, Req, State) ->
      lager:info("WS info ~p ~n",[Msg]),
      unsubscribe_if_starting_new_game(Msg),
      {reply, {text, jsx:encode(transform(Msg))}, Req, waiting_state(Msg, State)}.
  
  unsubscribe_if_starting_new_game({players,_}) ->
      admin:unsubscribe(self());
  unsubscribe_if_starting_new_game(_) ->
      ok.
  
  websocket_terminate(Reason, _Req, {logged_in} = State) ->
  