several changes and trying to make it work, but still problems.
not sure how much is because the source code in the book has errors,
or is it because I don't understand these things properly?

This commit may not be an improvement over the previous, but still want
to keep what I did and tested.