bug fix in error path