Refactored scanning