added select and it breaks out of loop