% pseudocode — to be written