autocomplete funct. uses last applicable role
restructure where condition. add grouping