fix bugs for exercise 4b