refactor scanner