added calculation to the function