refactored common scanner functionality