Submitted code

Tested, fixed some errors and redone the output