Corrected EndsWith optimizer to take into account the third parameter