diff --git a/geomagio/api/ws/algorithms.py b/geomagio/api/ws/algorithms.py
index 6bf055c33ca2503897bbbbe0c8e264b373e78f75..eaf58451a4cc27c17ef1d3c4a2396e32a2fc7cfc 100644
--- a/geomagio/api/ws/algorithms.py
+++ b/geomagio/api/ws/algorithms.py
@@ -1,8 +1,8 @@
-from os import name
+import json
+
 from fastapi import APIRouter, Depends, HTTPException
 from starlette.responses import Response
 
-from ... import TimeseriesFactory
 from ...algorithm import DbDtAlgorithm
 from ...residual import (
     calculate,
@@ -44,6 +44,9 @@ def get_dbdt(
 )
 def calculate_residual(reading: Reading, adjust_reference: bool = True):
     try:
-        return calculate(reading=reading, adjust_reference=adjust_reference)
+        calculated = calculate(
+            reading=reading, adjust_reference=adjust_reference
+        ).json()
+        return json.loads(calculated.replace("NaN", "null"))
     except ValueError as e:
         raise HTTPException(status_code=400, detail=str(e))
diff --git a/geomagio/residual/Diagnostics.py b/geomagio/residual/Diagnostics.py
index fd9dac1c9e515e1e1033f5fb8735272ee15e1d57..42f8572a7372b9c03d8b90406db5d9235509ebd3 100644
--- a/geomagio/residual/Diagnostics.py
+++ b/geomagio/residual/Diagnostics.py
@@ -1,6 +1,5 @@
 from typing import Optional
 
-from .Measurement import Measurement
 from pydantic import BaseModel
 
 
@@ -14,4 +13,4 @@ class Diagnostics(BaseModel):
     """
 
     inclination: float
-    meridian: float
+    meridian: Optional[float] = None