Move logic of parsing input into own method