finished all chapter 2 challenge problems and made code slightly neater