modify the solution to p19