Improved errors handler