wrote problem2 functions, need error handling
wrote problem2 functions, need error handling