fixed loop in eggert code