added some comments.
this is the correct version.
Why are these lines different colors?