add selection callback, recognizers property and refactoring the code