prob 17 & 21, more clear solution for prob 20