Fixing merge problems that caused sintax error and changed functions order