improve errors handling