minor speed improvements to backwards for loops