part1 and part 2 working without any bugs. proper output formatting of part1 and 2