diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..0ed6303a9dea2723de409e333ac17d3ca4e586ab
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,6 @@
+# Default ignored files
+/workspace.xml
+
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c2d4450fe1f73bf0266940e1675922b27e7e05c4
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,10 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0">
+    <option name="myName" value="Project Default" />
+    <inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
+      <Languages>
+        <language minSize="146" name="Python" />
+      </Languages>
+    </inspection_tool>
+  </profile>
+</component>
\ No newline at end of file
diff --git a/property-pull.py b/property-pull.py
index a488b95716cdced10cba5f519fb939972184d75f..dc3714b3d04614e17074b69af90b903f0a2232f2 100644
--- a/property-pull.py
+++ b/property-pull.py
@@ -47,6 +47,10 @@ sums_cols = udf(lambda arr: 0 if arr == [] else __builtins__.sum(arr), IntegerTy
 '''
 
 
+def write_file(_device, _start_time, _end_time, _property, data):
+    write_file(_device, _start_time, _end_time, _property, data)
+
+
 def uncompress(_data_array, _index_array, _size, _nrows):
     print('uncompress start')
     result = np.zeros(_size, dtype=np.int)
@@ -243,14 +247,7 @@ def pull_integral(_start_time, _end_time, _device):
     db_cursor = mydb.cursor()
     db_cursor.execute('UPDATE data SET integral = %s where id = %s', (json.dumps(data), data_id,))
 
-    if _files:
-        # Writing output #
-        with open(_dest_dir + '/' + _device + '_' + _start_time.replace(' ', '_') + 'to'
-                  + _end_time.replace(' ', '_') + '_' + _property + '.dat', 'w') as outfile:
-            json.dump(data, outfile)
-
-        print(_dest_dir + '/' + _device + '_' + _start_time.replace(' ', '_') + 'to'
-              + _end_time.replace(' ', '_') + '_' + _property + '.dat' + " Pulled")
+    write_file(_device, _start_time, _end_time, _property, data)
 
 
 # Not Working with too mny dat (dump memory)
@@ -323,14 +320,7 @@ def pull_raw_dist(_start_time, _end_time, _device):
     db_cursor = mydb.cursor()
     db_cursor.execute('UPDATE data SET raw_dist = %s where id = %s', (json.dumps(data), data_id,))
 
-    if _files:
-        # Writing output #
-        with open(_dest_dir + '/' + _device + '_' + _start_time.replace(' ', '_') + 'to'
-                  + _end_time.replace(' ', '_') + '_' + _property + '.dat', 'w') as outfile:
-            json.dump(data, outfile)
-
-        print(_dest_dir + '/' + _device + '_' + _start_time.replace(' ', '_') + 'to'
-              + _end_time.replace(' ', '_') + '_' + _property + '.dat' + " Pulled")
+    write_file(_device, _start_time, _end_time, _property, data)
 
 
 def pull_integral_dist(_start_time, _end_time, _device):
@@ -406,14 +396,7 @@ def pull_integral_dist(_start_time, _end_time, _device):
     db_cursor = mydb.cursor()
     db_cursor.execute('UPDATE data SET integral_dist = %s where id = %s', (json.dumps(data), data_id,))
 
-    if _files:
-        # Writing output #
-        with open(_dest_dir + '/' + _device + '_' + _start_time.replace(' ', '_') + 'to'
-                  + _end_time.replace(' ', '_') + '_' + _property + '.dat', 'w') as outfile:
-            json.dump(data, outfile)
-
-        print(_dest_dir + '/' + _device + '_' + _start_time.replace(' ', '_') + 'to'
-              + _end_time.replace(' ', '_') + '_' + _property + '.dat' + " Pulled")
+    write_file(_device, _start_time, _end_time, _property, data)
 
 
 def pull_turnloss(_start_time, _end_time, _device):
@@ -504,14 +487,7 @@ def pull_turnloss(_start_time, _end_time, _device):
     db_cursor = mydb.cursor()
     db_cursor.execute('UPDATE data SET turnloss = %s where id = %s', (json.dumps(data), data_id,))
 
-    if _files:
-        # Writing output #
-        with open(_dest_dir + '/' + _device + '_' + _start_time.replace(' ', '_') + 'to'
-                  + _end_time.replace(' ', '_') + '_' + _property + '.dat', 'w') as outfile:
-            json.dump(data, outfile)
-
-        print(_dest_dir + '/' + _device + '_' + _start_time.replace(' ', '_') + 'to'
-              + _end_time.replace(' ', '_') + '_' + _property + '.dat' + " Pulled")
+    write_file(_device, _start_time, _end_time, _property, data)
 
 
 if __name__ == '__main__':