created 'createScanner' method to remove repetition