improved error handing