working code without notes
Added comments