Optimization of the wastewater treatment plant: From energy saving to environmental impact mitigation