2nd optimization pass