further improvement on chapter 5