Fix compile-time errors.

You were just trying to use a variable that didn't exist. The algorithm
seems to work just fine.