refactored to a input data, algorithm, output data structure