auto complete logic