refactored into input/output classes, interfaces, inheritance