updates to calculate algorithm