scanner refactor