Fix midoid assignment
DOCUMENT ALL THE FUNCTIONS