refactored scan command