refactored scan