fix last node optimization error