refactored to make selector handling more robust

requires https://github.com/jackalope/jackalope/pull/185