extract method as described on pg.17