Finished solution code