improve errors handler