fixed error code not being returned