calculate result function