added error log trying to fix query replace bug