Refactored scanner