Thanks to everyone for contributing! It was really neat to read everyone's ideas and see the discussion and review (talking about code is always fun!). Here is a summary of responses and the "fixed" code. If you are interested in the original problem, go here . @drakiula...