diff --git a/.gitignore b/.gitignore
index f4a7742f164ff20f1ea065b4f337751f267f58b5..d3c652fd439d8383ba3a20db17a1b4500514e910 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,8 @@ config.py
 /embody
 /app/static/lib
 .env
+/app/static/*.png
+/app/static/embody_images
+.vscode/
+documentation
 
diff --git a/app/experiment/views.py b/app/experiment/views.py
index 6b02e510950e60e156b686cefddd00646103b2a7..1571725eefd24a2dd4aaaacd80d6f2a383a6e0d2 100644
--- a/app/experiment/views.py
+++ b/app/experiment/views.py
@@ -19,6 +19,7 @@ from flask import (
 from wtforms import Form
 from sqlalchemy import and_, update
 from flask_login import login_required
+from werkzeug import secure_filename
 
 from app import app, db 
 from app.routes import APP_ROOT
@@ -35,7 +36,8 @@ from app.forms import (
     EditQuestionForm, EditExperimentForm, UploadResearchBulletinForm, 
     EditPageForm, RemoveExperimentForm, GenerateIdForm,CreateEmbodyForm
 )
-from werkzeug import secure_filename
+from app.utils import get_mean_from_slider_answers 
+
 
 #Stimuli upload folder setting
 #APP_ROOT = os.path.dirname(os.path.abspath(__file__))
@@ -916,19 +918,13 @@ def statistics():
         
     #List of answers per participant in format question Stimulus ID/Question ID
     #those are in answer table as page_idpage and question_idquestion respectively
-
     slider_answers = {}
     for participant in participants:
-
-        # list only finished answer sets
-        if experiment_page_count == participant.answer_counter:
+        if participant.answer_counter > 0:
             answers = answer.query.filter_by(answer_set_idanswer_set=participant.idanswer_set).all()     
             slider_answers[participant.session] = [ a.answer for a in answers]     
 
-    # map slider_answers from str to int and calculate mean
-    a = [map(int,i) for i in list(slider_answers.values())]
-    slider_answers['mean'] = [round(float(sum(l))/len(l), 2) for l in zip(*a)]
-
+    slider_answers['mean'] = get_mean_from_slider_answers(slider_answers)
 
     #Background question answers
     bg_questions = background_question.query.filter_by(
@@ -936,9 +932,7 @@ def statistics():
     bg_answers_for_participants = {}
 
     for participant in participants:
-
-        # list only finished answer sets
-        if experiment_page_count == participant.answer_counter:
+        if participant.answer_counter > 0:
             bg_answers = background_question_answer.query.filter_by(
                 answer_set_idanswer_set=participant.idanswer_set).all()
             bg_answers_list = [(a.answer) for a in bg_answers]
@@ -982,6 +976,9 @@ def create_embody():
 
 @socketio.on('draw', namespace="/create_embody")
 def create_embody(page_id):
+
+    print("DRAW")
+
     page = page_id["page"]
     embody = page_id["embody"]
 
diff --git a/app/routes.py b/app/routes.py
index 342fcb19825935a067d22e8d145fe361c2a48a86..83244812051b46e00931a5989d25b0fe787e0b58 100644
--- a/app/routes.py
+++ b/app/routes.py
@@ -360,14 +360,6 @@ def download_csv():
     # embody questions
     embody_questions = embody_question.query.filter_by(experiment_idexperiment=exp_id).all()
 
-    #started and finished ratings counters
-    started_ratings = answer_set.query.filter_by(
-        experiment_idexperiment=exp_id).count()
-    experiment_page_count = page.query.filter_by(
-        experiment_idexperiment=exp_id).count()
-    finished_ratings = answer_set.query.filter(and_(
-        answer_set.answer_counter == experiment_page_count, answer_set.experiment_idexperiment == exp_id)).count()
-
     csv = ''
 
     # create CSV-header
@@ -377,6 +369,7 @@ def download_csv():
     for idx in range(1,len(pages) + 1):
         if len(questions) > 0:
             header += ';' + ';'.join(['page' + str(idx) + '_' + str(count) +'. slider_question: ' + question.question.strip() for count,question in enumerate(questions, 1)]) 
+
     for idx in range(1,len(pages) + 1):
         if len(embody_questions) > 0:
             header += ';' + ';'.join(['page' + str(idx) + '_' + str(count) +'. embody_question: '+ question.picture.strip() for count,question in enumerate(embody_questions, 1)])
@@ -385,12 +378,9 @@ def download_csv():
     answer_row = ''
 
     for participant in participants:
-
         # list only finished answer sets
-        if experiment_page_count == participant.answer_counter:
-
+        if participant.answer_counter > 0:
             try:
-
                 # append user session id
                 answer_row += participant.session + ';'
 
@@ -408,6 +398,9 @@ def download_csv():
                 # save embody answers as bitmap images  
                 embody_answers = embody_answer.query.filter_by(answer_set_idanswer_set=participant.idanswer_set).all()     
                 answers_list = []
+
+                # TODO: check randomization
+
                 for embody_answer_data in embody_answers:
 
                     try:
diff --git a/app/static/js/getDrawing.js b/app/static/js/getDrawing.js
index ed1a11d87e2dd09ac7b5760f1953ef3da571a88b..919c72755e0be198062b46b8f66bdb09a810235d 100644
--- a/app/static/js/getDrawing.js
+++ b/app/static/js/getDrawing.js
@@ -1,6 +1,7 @@
 
 
-const baseURI = 'http://onni.utu.fi/';
+const baseURI = 'localhost/';
+//const baseURI = 'http://onni.utu.fi/';
 var getDrawingURI = baseURI + 'create_embody';
 
 $(document).ready(function()  {
diff --git a/app/task/views.py b/app/task/views.py
index e72588f910ab45bce172f12aa3904bfcb8d7bfb8..c7815a3fe029877962b406bb7ae359386288f4b3 100644
--- a/app/task/views.py
+++ b/app/task/views.py
@@ -37,14 +37,11 @@ task_blueprint = Blueprint("task", __name__,
 def get_randomized_page(page_id):
     """if trial randomization is on we will still use the same functionality that is used otherwise
     but we will pass the randomized pair of the page_id from trial randomization table to the task.html"""
-
-    randomized_page = trial_randomization.query.filter(and_(
+    return trial_randomization.query.filter(and_(
             trial_randomization.answer_set_idanswer_set==session['answer_set'], 
             trial_randomization.page_idpage==page_id
         )).first()
 
-    return randomized_page
-
 
 def add_slider_answer(key, value, page_id=None):
     """Insert slider value to database. If trial randomization is set to 'Off' 
diff --git a/app/utils.py b/app/utils.py
new file mode 100644
index 0000000000000000000000000000000000000000..f7a9d257b3cf09639656011945b33b46e4958e09
--- /dev/null
+++ b/app/utils.py
@@ -0,0 +1,17 @@
+from itertools import zip_longest
+
+
+def map_values_to_int(values: dict):
+    values = [map(int, i) for i in list(values.values())]
+    return zip_longest(*values, fillvalue=None)
+
+
+def calculate_mean(values: list) -> float:
+    n_answers = sum(x is not None for x in values)
+    sum_of_answers = float(sum(filter(None, values)))
+    mean = sum_of_answers / n_answers
+    return round(mean, 2)
+
+
+def get_mean_from_slider_answers(answers):
+    return [calculate_mean(values) for values in map_values_to_int(answers)]