Added logic to handle non-JSON data