Altered Code to match example from class notes