Added notes and code listing
and fix typo