Scanner refactoring