Added iteration decrements to avoid skipping over elements in certain circumstances