Completed extra credit for example 6