modified code to match example code from class
Added Exceptions