refactored code, added javadoc comments and added sample output files