added norvigs code