implement selection function