modify the solution to p27