fixed bug on selection loop