Add calculation of main function