first untested version of selection detection