Submission of working code. Tested.