diff --git a/.gitignore b/.gitignore
index 4542d77e1428b2a56b55d3ffe056d5a92dd85293..d4f6506ae42c12be009c1a4254f82a878a22df72 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@ __pycache__/
 
 # C extensions
 *.so
+utils.c
 
 # Distribution / packaging
 .Python
diff --git a/setup.py b/setup.py
index 8d9e046616da50b74de00af1caeb8c6750ad26f9..4f2224a6a1a7cfa7ff6cdfaafb859ffb3733f979 100644
--- a/setup.py
+++ b/setup.py
@@ -1,3 +1,5 @@
+from Cython.Build import cythonize
+from setuptools.extension import Extension
 from setuptools import find_packages, setup
 
 with open('README.rst') as readme_file:
@@ -32,6 +34,7 @@ setup(
     keywords='stpt_pipeline',
     name='stpt_pipeline',
     packages=find_packages(include=['stpt_pipeline']),
+    ext_modules=cythonize(Extension('stpt_pipeline.utils', ['stpt_pipeline/utils.pyx'])),
     setup_requires=setup_requirements,
     test_suite='tests',
     tests_require=test_requirements,
diff --git a/stpt_pipeline/settings.py b/stpt_pipeline/settings.py
index 0df70392bc4b161f3c2fffbd84c82e1289466a09..fe613b09f74267c6bfdd23dea7c907b82dcd9a8e 100644
--- a/stpt_pipeline/settings.py
+++ b/stpt_pipeline/settings.py
@@ -25,4 +25,4 @@ class Settings:
     do_flat = True
     do_defringe = False
     channel_to_use = 4
-    cof_dist = np.array([3.93716645e-05, -7.37696218e-02, 2.52457306e01]) / 2.0
+    cof_dist = (3.93716645e-05 / 2, -7.37696218e-02 / 2, 2.52457306e01 / 2)
diff --git a/stpt_pipeline/stpt_displacement.py b/stpt_pipeline/stpt_displacement.py
index 1f7b53b5aeaa08dd60a8d7335f184d1c7c51c248..91d0b1d2773ec93f88b7bcb8712ca38e4b3b33f7 100644
--- a/stpt_pipeline/stpt_displacement.py
+++ b/stpt_pipeline/stpt_displacement.py
@@ -60,52 +60,6 @@ def defringe(img):
     return fr_img
 
 
-#
-#  get_coords is the function that feeds geometric_transform
-# in order to correct for the optical distortion of the detector.
-#
-def get_coords(coords, cof, center_x, max_x, direct=True):
-    """[summary]
-
-    Parameters
-    ----------
-    coords : [type]
-        [description]
-    cof : [type]
-        [description]
-    center_x : [type]
-        [description]
-    max_x : [type]
-        [description]
-    direct : bool, optional
-        [description], by default True
-
-    Returns
-    -------
-    [type]
-        [description]
-    """
-    max_desp = cof[0] * coords[1] ** 2 + cof[1] * coords[1] + cof[2]
-    dy_cof = max_desp / (max_x - center_x) ** 2
-    if direct:
-        if coords[0] > center_x:
-            sign = 1
-        else:
-            sign = -1
-        xi = np.abs(coords[0] - center_x)
-        return (center_x + sign * (xi + dy_cof * xi ** 2), coords[1])
-    else:
-        if coords[0] > center_x + cof[2]:
-            sign = 1
-        else:
-            sign = -1
-        xi = np.abs(coords[0] - center_x - cof[2])
-        return (
-            center_x + sign * (np.sqrt(1 + 4 * dy_cof * xi) - 1) / (2 * dy_cof),
-            coords[1],
-        )
-
-
 def magic_function(x, flat=1):  # TODO: Call this some other name
     """[summary]
 
diff --git a/stpt_pipeline/utils.pyx b/stpt_pipeline/utils.pyx
new file mode 100644
index 0000000000000000000000000000000000000000..d54b9cc9a92c2b88543d7d099f487e8b7d7d76e0
--- /dev/null
+++ b/stpt_pipeline/utils.pyx
@@ -0,0 +1,37 @@
+from libc.math cimport abs
+
+def get_coords(tuple coords, tuple cof, float center_x, float max_x):
+    """[summary]
+
+    Parameters
+    ----------
+    coords : [type]
+        [description]
+    cof : [type]
+        [description]
+    center_x : [type]
+        [description]
+    max_x : [type]
+        [description]
+
+    Returns
+    -------
+    [type]
+        [description]
+    """
+    cdef float max_desp, dy_cof, xi, r0, r1
+    cdef int c0, c1, sign
+    cdef tuple res
+    c0 = coords[0]
+    c1 = coords[1]
+    max_desp = cof[0] * c1 ** 2 + cof[1] * c1 + cof[2]
+    dy_cof = max_desp / (max_x - center_x) ** 2
+    if c0 > center_x:
+        sign = 1
+    else:
+        sign = -1
+    xi = abs(c0 - center_x)
+    r0 = center_x + sign * (xi + dy_cof * xi ** 2)
+    res = (r0, c1)
+    return res
+    
\ No newline at end of file