Updated the nested function names. Added comments for the document and to major functions