Fix for select(str)

Modified select logic to prevent early exist from loop.