fix element searching in error handler