fixing incorrect optimization