fix loop condition
do not overwrite tails
update results