diff --git a/sorter.py b/sorter.py
index b41213e70cc0d9fbdf9d33da2fc0d988872e3b8c..f7473b10946cdbe8b1d352e102306fad7859eb66 100644
--- a/sorter.py
+++ b/sorter.py
@@ -139,7 +139,7 @@ def sort_now():
 						if not 'format' in data:
 							data['format'] = 0
 						# insert the video into videos_data and log
-						insert_video( matches[0]['id'], dbfilepath, filepath, fileformatid)
+						insert_video( matches[0]['id'], dbfilepath, filepath, data['format'])
 					else:
 						# if we couldn't match the video on exactly one lecture, log an error
 						matches_id = []