more loop improvements