finished problem 17, but some error handling could still be done.