refactor and add comments
Merge remote-tracking branch 'origin/final_demo' into final_demo