progress on calculate function