improved error codes handling