Added check for valid json