applied changes to solution of chapter 6