Capturing the range variable out of a foreach block into a lambda expression is the bug. Here's an example of the common bug: http://stackoverflow.com/questions/235455/access-to-modified-closure