finished first two implmentations in problem set 1, 1st one may need to throw an exception