Separated out parseInput function