Final completed code