Finished PartA1 code