complex functions refactoring
+table result function tests