refactors the error code to be global