Refactors input, output, and calculations into distinct methods