scanner refactoring