potential infinite loop? how about a max tries counter and giving up if exceeded?