added selector refactorized some code