refactoring
moved io logic to common java code