Modify exercise 5.39 ~ 5.40