optimized code, added PrintOutput Method

added xml comments, all tests pass!