Finished working code.