Did some work on selection function.