Improve efficiency of getInput method