add error gestion and fix error