Solved a problem with error-passing