fixed 'selection' function