fixing the calculations