implementation of norvig's idea