Rewrite logic for isInputString() method