refactored and move the selector to function arg