make sure to handle error case correctly in todec