refactored out smartSelect