+\r
+\r
+\subsection{\textbf{Create new key}}\r
+\noindent\fbox{%\r
+\begin{varwidth}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}\r
+\textbf{Create new key:}\r
+\begin{algorithmic}[1]\r
+\Function{CreateNewKey}{$keyName, mid$}\r
+ \State $vc \gets $ \Call{GenerateVectorClock}{ }\r
+ \State $newKeyPayload \gets \tuple{keyName, vc, NULL, mid}$\r
+ \State $API \gets \emptyset$ \Comment{Set of all Payload Items}\\\r
+\r
+ \State \Call{GetLatestDataStruct}{ } \Comment{Update local version of data struct}\\\r
+\r
+ \ForAll{record in R}\r
+ \State $API \gets API \cup$ \Call{GetPayloadItemsWithSSN}{record}\r
+ \EndFor\\\r
+ \r
+ \ForAll{$\tuple{ssn, payload}$ in $API$}\r
+ \If{($payload$ is a $newkey) \land$ \Call{IsLive}{$payload, ssn$}}\r
+ \State $\tuple{k', vc', ssn', mid'} \gets payload$\r
+ \r
+ \If{$k' = key$}\r
+ \State \Return{False}\r
+ \EndIf\r
+ \EndIf\r
+ \EndFor\\\r
+ \r
+ \State \Call{InsertPayload}{$newKeyPayload$}\r
+ \State \Return{True}\r
+\EndFunction\r
+\end{algorithmic}\r
+\end{varwidth}% \r
+}\r
+\r