scan backwards optimization