fixes name compare end loop condition