diff --git a/db/Makefile b/db/Makefile
index c3dec2ace328d6759b482bdffa1ba0e98b5c3f0d..1861d42e35f2252d4e0fe90840444c53f2dccfcb 100644
--- a/db/Makefile
+++ b/db/Makefile
@@ -3,7 +3,7 @@ $(subst .sql, , $(wildcard $1/*.sql))
 endef
 
 
-USER := $(shell bash -c 'read -p "Username: " pwd; echo $$username')
+USER := $(shell bash -c 'read -p "Username: " username; echo $$username')
 PASS := $(shell bash -c 'read -s -p "Password: " pwd; echo $$pwd')
 DB := mmcs_rating
 
@@ -20,6 +20,6 @@ deploy: $(call GET_NAMES, stored)
 
 
 %:
-	mysql -u $(USER) $(PASS) $(DB) < $@.sql
+	mysql -u $(USER) --password=$(PASS) $(DB) < $@.sql
 
 
diff --git a/db/stored/functions.sql b/db/stored/functions.sql
index 301b1b1af295cc9f6a7a583e9ba7f5a2c198695d..5140eb921dfe547812f4846b1398b174f39a8540 100644
--- a/db/stored/functions.sql
+++ b/db/stored/functions.sql
@@ -104,7 +104,7 @@ BEGIN
                                             disciplines_groups.GroupID = students_groups.GroupID
         WHERE   students_groups.StudentID = pStudentID AND
                 students_groups.SemesterID = pSemesterID AND
-                students_groups.IsStudyLeave = FALSE
+                students_groups.State != 'expulsion'
         LIMIT 1
     );
 END //
@@ -360,7 +360,7 @@ BEGIN
         FROM `students_groups`
         WHERE   students_groups.StudentID = pStudentID AND
                 students_groups.SemesterID = pSemesterID AND
-                students_groups.IsStudyLeave = FALSE
+                students_groups.State != 'expulsion'
         LIMIT 1;
 
     RETURN vGroupID;