refactoring selector.js