final version

added comment on code, and complete the work.