Finished implementation for ex9