start of figure 20, but doesn't work correctly