diff --git a/histogram.cpp b/histogram.cpp
new file mode 100644
index 0000000..5bfcbfd
--- /dev/null
+++ b/histogram.cpp
@@ -0,0 +1,57 @@
+#include "histogram.h"
+#include <vector>
+
+static void find_minmax(const std::vector<double>& numbers, double& min, double& max)
+{
+    min = numbers[0];
+    for (double x : numbers)
+    {
+        if (x < min)
+        {
+            min = x;
+        }
+        else if (x > max)
+        {
+            max = x;
+        }
+    }
+}
+
+std::vector<double> make_histogram(const std::vector<double> &numbers, std::size_t bin_count)
+{
+    double min = numbers[0];
+    double max = numbers[0];
+    find_minmax(numbers, min, max);
+    double bin_size = (max - min) / bin_count;
+    std::vector<double>bins(bin_count);
+
+    for (std::size_t i = 0; i < numbers.size(); i++)
+    {
+        bool found = false;
+        for (std::size_t j = 0; (j < bin_count - 1) && !found; j++)
+        {
+            auto lo = min + j * bin_size;
+            auto hi = min + (j + 1) * bin_size;
+            if ((lo <= numbers[i]) && (numbers[i] < hi))
+            {
+                bins[j]++;
+                found = true;
+            }
+        }
+        if (!found)
+        {
+            bins[bin_count - 1]++;
+        }
+    }
+    double b;
+    for (std::size_t i = 0; i < bin_count-1; i++)
+    {
+        if (bins[i] > bins[i+1])
+        {
+            b = bins[i];
+            bins[i] = bins[i + 1];
+            bins[i + 1] = b;
+        }
+    }
+    return bins;
+}
diff --git a/histogram.h b/histogram.h
new file mode 100644
index 0000000..6d24980
--- /dev/null
+++ b/histogram.h
@@ -0,0 +1,5 @@
+#ifndef HISTOGRAM_H_INCLUDED
+#define HISTOGRAM_H_INCLUDED
+#include <vector>
+std::vector<double> make_histogram(const std::vector<double>& numbers, std::size_t bin_count);
+#endif // HISTOGRAM_H_INCLUDED
diff --git a/main.cpp b/main.cpp
index 1ca3faa..b5028a4 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,5 +1,7 @@
 #include <iostream>
 #include <vector>
+#include "histogram.h"
+#include "text.h"
 
 using namespace std;
 
@@ -26,110 +28,6 @@ Input input_data()
     return in;
 }
 
-void find_minmax(const vector<double>& numbers, double& min, double& max)
-{
-    min = numbers[0];
-    for (double x : numbers)
-    {
-        if (x < min)
-        {
-            min = x;
-        }
-        else if (x > max)
-        {
-            max = x;
-        }
-    }
-}
-
-vector<double> make_histogram(const vector<double> &numbers, size_t bin_count)
-{
-    double min = numbers[0];
-    double max = numbers[0];
-    find_minmax(numbers, min, max);
-    double bin_size = (max - min) / bin_count;
-    vector<double>bins(bin_count);
-    for (size_t i = 0; i < numbers.size(); i++)
-    {
-        bool found = false;
-        for (size_t j = 0; (j < bin_count - 1) && !found; j++)
-        {
-            auto lo = min + j * bin_size;
-            auto hi = min + (j + 1) * bin_size;
-            if ((lo <= numbers[i]) && (numbers[i] < hi))
-            {
-                bins[j]++;
-                found = true;
-            }
-        }
-        if (!found)
-        {
-            bins[bin_count - 1]++;
-        }
-    }
-
-    double b;
-    for (size_t i = 0; i < bin_count-1; i++)
-    {
-        if (bins[i] > bins[i+1])
-        {
-            b = bins[i];
-            bins[i] = bins[i + 1];
-            bins[i + 1] = b;
-        }
-    }
-    return bins;
-}
-
-void show_histogram_text(const vector <double> &bins)
-{
-    const size_t SCREEN_WIDTH = 80;
-    const size_t MAX_STAR = SCREEN_WIDTH - 3 - 1;
-    size_t max_star_search = bins[-1];
-
-    if (max_star_search > MAX_STAR)
-    {
-        for (size_t x : bins)
-        {
-            size_t height = MAX_STAR * (static_cast<double>(x) / max_star_search);
-            if (x < 100)
-            {
-                cout << " ";
-                if (x < 10)
-                {
-                    cout << " ";
-                }
-            }
-            cout << x << "|";
-            for (size_t i = 0; i < height; i++)
-            {
-                cout << "*";
-            }
-            cout << endl;
-        }
-    }
-    else
-    {
-        for (size_t x : bins)
-        {
-            if (x < 100)
-            {
-                cout << " ";
-                if (x < 10)
-                {
-                    cout << " ";
-                }
-            }
-            cout << x << "|";
-            for (size_t i = 0; i < x; i++)
-            {
-                cout << "*";
-            }
-            cout << endl;
-        }
-    }
-}
-
 int main()
 {
     auto in = input_data();
diff --git a/text.cpp b/text.cpp
new file mode 100644
index 0000000..a787216
--- /dev/null
+++ b/text.cpp
@@ -0,0 +1,52 @@
+#include <iostream>
+#include <vector>
+#include "text.h"
+
+void show_histogram_text(const std::vector <double> &bins)
+{
+    const size_t SCREEN_WIDTH = 80;
+    const size_t MAX_STAR = SCREEN_WIDTH - 3 - 1;
+    size_t max_star_search = bins[-1];
+
+    if (max_star_search > MAX_STAR)
+    {
+        for (size_t x : bins)
+        {
+            size_t height = MAX_STAR * (static_cast<double>(x) / max_star_search);
+            if (x < 100)
+            {
+                std::cout << " ";
+                if (x < 10)
+                {
+                    std::cout << " ";
+                }
+            }
+            std::cout << x << "|";
+            for (size_t i = 0; i < height; i++)
+            {
+                std::cout << "*";
+            }
+            std::cout << std::endl;
+        }
+    }
+    else
+    {
+        for (size_t x : bins)
+        {
+            if (x < 100)
+            {
+                std::cout << " ";
+                if (x < 10)
+                {
+                    std::cout << " ";
+                }
+            }
+            std::cout << x << "|";
+            for (size_t i = 0; i < x; i++)
+            {
+                std::cout << "*";
+            }
+            std::cout << std::endl;
+        }
+    }
+}
diff --git a/text.h b/text.h
new file mode 100644
index 0000000..4c08da5
--- /dev/null
+++ b/text.h
@@ -0,0 +1,5 @@
+#ifndef TEXT_H_INCLUDED
+#define TEXT_H_INCLUDED
+#include <vector>
+void show_histogram_text(const std::vector<double> &bins);
+#endif // TEXT_H_INCLUDED