ex 6.27. Runs but doesn't work properly.