Fix #239 -- next returns the first element

Fix #239 

@mglukhovsky -- can you take a look at this?