Refactored input() method.