baseline code from Peter Norvig
baseline code from Peter Norvig