Fix looped select bug