inserted error function when decode fails