add comments and move arg parse block for readability