simplified solution to ex 2.28 by removing use of append function