Better implementation for iterating over positions.
Removed assert which is in general wrong.