Iterator invalidation fix

[src/server_state.cpp:272] -> [src/server_state.cpp:274]: (error) Iterator 'i' used after element has been erased.