added calculateResult function