adding query to error log